client

package
v0.0.0-sei-fork Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 7 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(ctx context.Context, 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(ctx context.Context, c EventsClient, query string) (types.EventData, error)

WaitForOneEvent waits for the first event matching the given query on c, or until ctx ends. It reports an error if ctx ends before a matching event is received.

Types

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
	BroadcastTx(context.Context, types.Tx) (*coretypes.ResultBroadcastTx, error)
	// These methods are deprecated:
	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, which will run until the context terminates.
	// An error from Start indicates the client could not start.
	Start(context.Context) error

	ABCIClient
	EventsClient
	EvidenceClient
	HistoryClient
	MempoolClient
	NetworkClient
	SignClient
	StatusClient
	SubscriptionClient
}

Client describes the interface of Tendermint RPC client implementations.

type EventsClient

type EventsClient interface {
	// Events fetches a batch of events from the server matching the given query
	// and time range.
	Events(ctx context.Context, req *coretypes.RequestEvents) (*coretypes.ResultEvents, error)
}

EventsClient exposes the methods to retrieve events from the consensus engine.

type EvidenceClient

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, page, perPage *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

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) (*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.
	TxSearch(
		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
	// FinalizeBlock event search criteria.
	BlockSearch(
		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)
	LagStatus(context.Context) (*coretypes.ResultLagStatus, error)
}

StatusClient provides access to general chain info.

type SubscriptionClient

type SubscriptionClient interface {
	// Subscribe issues a subscription request for the given subscriber ID and
	// query. This method does not block: If subscription fails, it reports an
	// error, and if subscription succeeds it returns a channel that delivers
	// matching events until the subscription is stopped. The channel is never
	// closed; the client is responsible for knowing when no further data will
	// be sent.
	//
	// The context only governs the initial subscription, it does not control
	// the lifetime of the channel. To cancel a subscription call Unsubscribe or
	// UnsubscribeAll.
	//
	// Deprecated: This method will be removed in Tendermint v0.37, use Events
	// instead.
	Subscribe(ctx context.Context, subscriber, query string, outCapacity ...int) (out <-chan coretypes.ResultEvent, err error)

	// Unsubscribe unsubscribes given subscriber from query.
	//
	// Deprecated: This method will be removed in Tendermint v0.37, use Events
	// instead.
	Unsubscribe(ctx context.Context, subscriber, query string) error

	// UnsubscribeAll unsubscribes given subscriber from all the queries.
	//
	// Deprecated: This method will be removed in Tendermint v0.37, use Events
	// instead.
	UnsubscribeAll(ctx context.Context, subscriber string) error
}

TODO(creachadair): This interface should be removed once the streaming event interface is removed in Tendermint v0.37.

type Waiter

type Waiter func(delta int64) (abort error)

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

Directories

Path Synopsis
Package eventstream implements a convenience client for the Events method of the Tendermint RPC service, allowing clients to observe a resumable stream of events matching a query.
Package eventstream implements a convenience client for the Events method of the Tendermint RPC service, allowing clients to observe a resumable stream of events matching a query.

Jump to

Keyboard shortcuts

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