client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: Apache-2.0, Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultABCIQueryOptions = ABCIQueryOptions{Height: 0, Prove: false}

DefaultABCIQueryOptions are latest height (0) and prove false.

Functions

func DefaultWaitStrategy

func DefaultWaitStrategy(delta int64) (abort error)

DefaultWaitStrategy is the standard backoff algorithm, but you can plug in another one

func WaitForHeight

func WaitForHeight(c StatusClient, h int64, waiter Waiter) error

Wait for height will poll status at reasonable intervals until the block at the given height is available.

If waiter is nil, we use DefaultWaitStrategy, but you can also provide your own implementation

func WaitForOneEvent

func WaitForOneEvent(c EventsClient, evtTyp string, timeout time.Duration) (types.TMEventData, error)

WaitForOneEvent subscribes to a websocket event for the given event time and returns upon receiving it one time, or when the timeout duration has expired.

This handles subscribing and unsubscribing under the hood

Types

type ABCIClient

type ABCIClient interface {
	// Reading from abci app
	ABCIInfo() (*ctypes.ResultABCIInfo, error)
	ABCIQuery(path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error)
	ABCIQueryWithOptions(path string, data bytes.HexBytes,
		opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)

	// Writing to abci app
	BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
	BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
	BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
}

ABCIClient groups together the functionality that principally affects the ABCI app.

In many cases this will be all we want, so we can accept an interface which is easier to mock.

type ABCIQueryOptions

type ABCIQueryOptions struct {
	Height int64
	Prove  bool
}

ABCIQueryOptions can be used to provide options for ABCIQuery call other than the DefaultABCIQueryOptions.

type Client

Client wraps most important rpc calls a client would make if you want to listen for events, test if it also implements events.EventSwitch.

type EventsClient

type EventsClient interface {
	// Subscribe subscribes given subscriber to query. Returns a channel with
	// cap=1 onto which events are published. An error is returned if it fails to
	// subscribe. outCapacity can be used optionally to set capacity for the
	// channel. Channel is never closed to prevent accidental reads.
	//
	// ctx cannot be used to unsubscribe. To unsubscribe, use either Unsubscribe
	// or UnsubscribeAll.
	Subscribe(ctx context.Context, subscriber, query string, outCapacity ...int) (out <-chan ctypes.ResultEvent, err error)
	// Unsubscribe unsubscribes given subscriber from query.
	Unsubscribe(ctx context.Context, subscriber, query string) error
	// UnsubscribeAll unsubscribes given subscriber from all the queries.
	UnsubscribeAll(ctx context.Context, subscriber string) error
}

EventsClient is reactive, you can subscribe to any message, given the proper string. see tendermint/types/events.go

type EvidenceClient

type EvidenceClient interface {
	BroadcastEvidence(ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error)
}

EvidenceClient is used for submitting an evidence of the malicious behaviour.

type HistoryClient

type HistoryClient interface {
	Genesis() (*ctypes.ResultGenesis, error)
	BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)
	LatestBlockNumber() (int64, error)
	HeightByBtcHash(string) (int64, error)
	BtcBlockHashByBtcTxid(string) (string, error)
	BtcBlockHashByBtcHeight(int64) (string, error)
	MapTxhashTxid(btcHash, protocolName string) (map[string]string, error)
}

HistoryClient provides access to data from genesis to now in large chunks.

type MempoolClient

type MempoolClient interface {
	UnconfirmedTxs(limit int) (*ctypes.ResultUnconfirmedTxs, error)
	NumUnconfirmedTxs() (*ctypes.ResultUnconfirmedTxs, error)
	UserUnconfirmedTxs(address string, limit int) (*ctypes.ResultUserUnconfirmedTxs, error)
	UserNumUnconfirmedTxs(address string) (*ctypes.ResultUserUnconfirmedTxs, error)
	GetUnconfirmedTxByHash(hash [sha256.Size]byte) (types.Tx, error)
	GetAddressList() (*ctypes.ResultUnconfirmedAddresses, error)
	GetPendingNonce(address string) (*ctypes.ResultPendingNonce, bool)
}

MempoolClient shows us data about current mempool state.

type NetworkClient

type NetworkClient interface {
	NetInfo() (*ctypes.ResultNetInfo, error)
	DumpConsensusState() (*ctypes.ResultDumpConsensusState, error)
	ConsensusState() (*ctypes.ResultConsensusState, error)
	ConsensusParams(height *int64) (*ctypes.ResultConsensusParams, error)
	Health() (*ctypes.ResultHealth, error)
}

NetworkClient is general info about the network state. May not be needed usually.

type SignClient

type SignClient interface {
	Block(height *int64) (*ctypes.ResultBlock, error)
	BlockByHash(hash []byte) (*ctypes.ResultBlock, error)
	BlockInfo(height *int64) (*types.BlockMeta, error)
	BlockResults(height *int64) (*ctypes.ResultBlockResults, error)
	Commit(height *int64) (*ctypes.ResultCommit, error)
	Validators(height *int64, page, perPage int) (*ctypes.ResultValidators, error)
	Tx(hash []byte, prove bool) (*ctypes.ResultTx, error)
	TxSearch(query string, prove bool, page, perPage int, orderBy string) (*ctypes.ResultTxSearch, error)
}

SignClient groups together the functionality needed to get valid signatures and prove anything about the chain.

type StatusClient

type StatusClient interface {
	Status() (*ctypes.ResultStatus, error)
}

StatusClient provides access to general chain info.

type Waiter

type Waiter func(delta int64) (abort error)

Waiter is informed of current height, decided whether to quit early

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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