client

package
v0.41.7 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 8 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(context.Context) (*ctypes.ResultABCIInfo, error)
	ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error)
	ABCIQueryWithOptions(ctx context.Context, path string, data bytes.HexBytes,
		opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)

	// Writing to abci app
	BroadcastTxCommit(context.Context, types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
	BroadcastTxAsync(context.Context, types.Tx) (*ctypes.ResultBroadcastTx, error)
	BroadcastTxSync(context.Context, 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 added in v0.40.0

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

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

type HistoryClient

type HistoryClient interface {
	Genesis(context.Context) (*ctypes.ResultGenesis, error)
	GenesisChunked(context.Context, uint) (*ctypes.ResultGenesisChunk, error)
	BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)
}

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

type MempoolClient

type MempoolClient interface {
	UnconfirmedTxs(ctx context.Context, limit *int) (*ctypes.ResultUnconfirmedTxs, error)
	NumUnconfirmedTxs(context.Context) (*ctypes.ResultUnconfirmedTxs, error)
	CheckTx(context.Context, types.Tx) (*ctypes.ResultCheckTx, error)
}

MempoolClient shows us data about current mempool state.

type NetworkClient

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

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

type RemoteClient added in v0.40.0

type RemoteClient interface {
	Client

	// Remote returns the remote network address in a string form.
	Remote() string
}

RemoteClient is a Client, which can also return the remote network address.

type SignClient

type SignClient interface {
	Block(ctx context.Context, height *int64) (*ctypes.ResultBlock, error)
	BlockByHash(ctx context.Context, hash []byte) (*ctypes.ResultBlock, error)
	BlockResults(ctx context.Context, height *int64) (*ctypes.ResultBlockResults, error)
	Commit(ctx context.Context, height *int64) (*ctypes.ResultCommit, error)
	Validators(ctx context.Context, height *int64, page, perPage *int) (*ctypes.ResultValidators, error)
	Tx(ctx context.Context, hash []byte, prove bool) (*ctypes.ResultTx, error)

	// TxSearch defines a method to search for a paginated set of transactions by
	// DeliverTx event search criteria.
	TxSearch(
		ctx context.Context,
		query string,
		prove bool,
		page, perPage *int,
		orderBy string,
	) (*ctypes.ResultTxSearch, error)

	// BlockSearch defines a method to search for a paginated set of blocks by
	// BeginBlock and EndBlock event search criteria.
	BlockSearch(
		ctx context.Context,
		query string,
		page, perPage *int,
		orderBy string,
	) (*ctypes.ResultBlockSearch, error)
}

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

type StatusClient

type StatusClient interface {
	Status(context.Context) (*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