client

package
v0.1.429-bweng-test-1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountInfo

type AccountInfo struct {
	AccountNumber       uint64
	AccountSequence     uint64
	ShouldResetSequence bool
}

func (*AccountInfo) ObtainAccountInfo

func (accountInfo *AccountInfo) ObtainAccountInfo(ctx client.Context, txf tx.Factory, logger zerolog.Logger) (tx.Factory, error)

ObtainAccountInfo ensures the account defined by ctx.GetFromAddress() exists. We keep a local copy of account sequence number and manually increment it. If the local sequence number is 0, we will initialize it with the latest value getting from the chain.

func (*AccountInfo) ResetAccountSequence

func (accountInfo *AccountInfo) ResetAccountSequence(ctx client.Context, txf tx.Factory, logger zerolog.Logger) error

ResetAccountSequence will reset account sequence number to the latest sequence number in the chain

type HeightUpdater

type HeightUpdater struct {
	Logger        zerolog.Logger
	LastHeight    int64
	ChBlockHeight chan int64
}

HeightUpdater is used to provide the updates of the latest chain It starts a goroutine to subscribe to new block event and send the latest block height to the channel

func (HeightUpdater) Start

func (heightUpdater HeightUpdater) Start(
	ctx context.Context,
	rpcClient tmrpcclient.Client,
	logger zerolog.Logger,
) error

Start will start a new goroutine subscribed to EventNewBlockHeader.

type OracleClient

type OracleClient struct {
	Logger              zerolog.Logger
	ChainID             string
	KeyringBackend      string
	KeyringDir          string
	KeyringPass         string
	TMRPC               string
	RPCTimeout          time.Duration
	OracleAddr          sdk.AccAddress
	OracleAddrString    string
	ValidatorAddr       sdk.ValAddress
	ValidatorAddrString string
	FeeGranterAddr      sdk.AccAddress
	Encoding            simappparams.EncodingConfig
	GasPrices           string
	GasAdjustment       float64
	GRPCEndpoint        string
	KeyringPassphrase   string
	BlockHeightEvents   chan int64
}

OracleClient defines a structure that interfaces with the Umee node.

func NewOracleClient

func NewOracleClient(
	ctx context.Context,
	logger zerolog.Logger,
	chainID string,
	keyringBackend string,
	keyringDir string,
	keyringPass string,
	tmRPC string,
	rpcTimeout time.Duration,
	oracleAddrString string,
	validatorAddrString string,
	feeGranterAddrString string,
	grpcEndpoint string,
	gasAdjustment float64,
	gasPrices string,
) (OracleClient, error)

func (OracleClient) BroadcastTx

func (oc OracleClient) BroadcastTx(
	clientCtx client.Context,
	msgs ...sdk.Msg) (*sdk.TxResponse, error)

BroadcastTx attempts to broadcast a signed transaction in best effort mode. Retry is not needed since we are doing this for every new block as fast as we could. Ref: https://github.com/terra-money/oracle-feeder/blob/baef2a4a02f57a2ffeaa207932b2e03d7fb0fb25/feeder/src/vote.ts#L230

BroadcastTx attempts to generate, sign and broadcast a transaction with the given set of messages. It will also simulate gas requirements if necessary. It will return an error upon failure. We maintain a local account sequence number in txAccount and we manually increment the sequence number by 1 if the previous broadcastTx succeed.

func (OracleClient) CreateClientContext

func (oc OracleClient) CreateClientContext() (client.Context, error)

CreateClientContext creates an SDK client Context instance used for transaction generation, signing and broadcasting.

func (OracleClient) CreateTxFactory

func (oc OracleClient) CreateTxFactory() (tx.Factory, error)

CreateTxFactory creates an SDK Factory instance used for transaction generation, signing and broadcasting.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL