Version: v0.35.9 Latest Latest

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

Go to latest
Published: Jul 20, 2022 License: Apache-2.0 Imports: 9 Imported by: 1,014




This section is empty.


View Source
var (
	// ErrClientRunning is returned by Start when the client is already running.
	ErrClientRunning = errors.New("client already running")

	// ErrClientNotRunning is returned by Stop when the client is not running.
	ErrClientNotRunning = errors.New("client is not running")
View Source
var DefaultABCIQueryOptions = ABCIQueryOptions{Height: 0, Prove: false}

DefaultABCIQueryOptions are latest height (0) and prove false.


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, eventValue 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


type ABCIClient

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

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

type Client interface {

	// Start the client. Start must report an error if the client is running.
	Start() error

	// Stop the client. Stop must report an error if the client is not running.
	Stop() error

	// IsRunning reports whether the client is running.
	IsRunning() bool

	// These embedded interfaces define the callable methods of the service.

Client describes the interface of Tendermint RPC client implementations.

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 (out <-chan coretypes.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.32.2

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

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

type HistoryClient

type HistoryClient interface {
	Genesis(context.Context) (*coretypes.ResultGenesis, error)
	GenesisChunked(context.Context, uint) (*coretypes.ResultGenesisChunk, error)
	BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*coretypes.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) (*coretypes.ResultUnconfirmedTxs, error)
	NumUnconfirmedTxs(context.Context) (*coretypes.ResultUnconfirmedTxs, error)
	CheckTx(context.Context, types.Tx) (*coretypes.ResultCheckTx, error)
	RemoveTx(context.Context, types.TxKey) error

MempoolClient shows us data about current mempool state.

type NetworkClient

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

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

type RemoteClient added in v0.34.0

type RemoteClient interface {

	// 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 RunState added in v0.35.0

type RunState struct {
	Logger log.Logger
	// contains filtered or unexported fields

RunState is a helper that a client implementation can embed to implement common plumbing for keeping track of run state and logging.

TODO(creachadair): This type is a temporary measure, and will be removed. See the discussion on #6971.

func NewRunState added in v0.35.0

func NewRunState(name string, logger log.Logger) *RunState

NewRunState returns a new unstarted run state tracker with the given logging label and log sink. If logger == nil, a no-op logger is provided by default.

func (*RunState) IsRunning added in v0.35.0

func (r *RunState) IsRunning() bool

IsRunning reports whether the state is running.

func (*RunState) Quit added in v0.35.0

func (r *RunState) Quit() <-chan struct{}

Quit returns a channel that is closed when a call to Stop succeeds.

func (*RunState) SetLogger added in v0.35.0

func (r *RunState) SetLogger(logger log.Logger)

SetLogger updates the log sink.

func (*RunState) Start added in v0.35.0

func (r *RunState) Start() error

Start sets the state to running, or reports an error.

func (*RunState) Stop added in v0.35.0

func (r *RunState) Stop() error

Stop sets the state to not running, or reports an error.

type SignClient

type SignClient interface {
	Block(ctx context.Context, height *int64) (*coretypes.ResultBlock, error)
	BlockByHash(ctx context.Context, hash bytes.HexBytes) (*coretypes.ResultBlock, error)
	BlockResults(ctx context.Context, height *int64) (*coretypes.ResultBlockResults, error)
	Header(ctx context.Context, height *int64) (*coretypes.ResultHeader, error)
	HeaderByHash(ctx context.Context, hash bytes.HexBytes) (*coretypes.ResultHeader, error)
	Commit(ctx context.Context, height *int64) (*coretypes.ResultCommit, error)
	Validators(ctx context.Context, height *int64, page, perPage *int) (*coretypes.ResultValidators, error)
	Tx(ctx context.Context, hash bytes.HexBytes, prove bool) (*coretypes.ResultTx, error)

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

	// BlockSearch defines a method to search for a paginated set of blocks by
	// BeginBlock and EndBlock event search criteria.
		ctx context.Context,
		query string,
		page, perPage *int,
		orderBy string,
	) (*coretypes.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) (*coretypes.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


Path Synopsis

Jump to

Keyboard shortcuts

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