Documentation ¶
Index ¶
- Variables
- func DefaultWaitStrategy(delta int64) (abort error)
- func WaitForHeight(c StatusClient, h int64, waiter Waiter) error
- func WaitForOneEvent(c EventsClient, evtTyp string, timeout time.Duration) (types.TMEventData, error)
- type ABCIClient
- type ABCIQueryOptions
- type Client
- type EventsClient
- type EvidenceClient
- type HistoryClient
- type MempoolClient
- type NetworkClient
- type SignClient
- type StatusClient
- type Waiter
Constants ¶
This section is empty.
Variables ¶
var DefaultABCIQueryOptions = ABCIQueryOptions{Height: 0, Prove: false}
DefaultABCIQueryOptions are latest height (0) and prove false.
Functions ¶
func DefaultWaitStrategy ¶
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 ¶
ABCIQueryOptions can be used to provide options for ABCIQuery call other than the DefaultABCIQueryOptions.
type Client ¶
type Client interface { service.Service ABCIClient EventsClient HistoryClient NetworkClient SignClient StatusClient EvidenceClient MempoolClient }
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) }
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) }
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) 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.