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 BatchHTTP
- func (c BatchHTTP) ABCIInfo() (*ctypes.ResultABCIInfo, error)
- func (c BatchHTTP) ABCIQuery(path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error)
- func (c BatchHTTP) ABCIQueryWithOptions(path string, data bytes.HexBytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
- func (c BatchHTTP) Block(height *int64) (*ctypes.ResultBlock, error)
- func (c BatchHTTP) BlockResults(height *int64) (*ctypes.ResultBlockResults, error)
- func (c BatchHTTP) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)
- func (c BatchHTTP) BroadcastEvidence(ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error)
- func (c BatchHTTP) BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- func (c BatchHTTP) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
- func (c BatchHTTP) BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- func (b *BatchHTTP) Clear() int
- func (c BatchHTTP) Commit(height *int64) (*ctypes.ResultCommit, error)
- func (c BatchHTTP) ConsensusParams(height *int64) (*ctypes.ResultConsensusParams, error)
- func (c BatchHTTP) ConsensusState() (*ctypes.ResultConsensusState, error)
- func (b *BatchHTTP) Count() int
- func (c BatchHTTP) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error)
- func (c BatchHTTP) Genesis() (*ctypes.ResultGenesis, error)
- func (c BatchHTTP) Health() (*ctypes.ResultHealth, error)
- func (c BatchHTTP) NetInfo() (*ctypes.ResultNetInfo, error)
- func (c BatchHTTP) NumUnconfirmedTxs() (*ctypes.ResultUnconfirmedTxs, error)
- func (b *BatchHTTP) Send() ([]interface{}, error)
- func (c BatchHTTP) Status() (*ctypes.ResultStatus, error)
- func (c BatchHTTP) Tx(hash []byte, prove bool) (*ctypes.ResultTx, error)
- func (c BatchHTTP) TxSearch(query string, prove bool, page, perPage int, orderBy string) (*ctypes.ResultTxSearch, error)
- func (c BatchHTTP) UnconfirmedTxs(limit int) (*ctypes.ResultUnconfirmedTxs, error)
- func (c BatchHTTP) Validators(height *int64, page, perPage int) (*ctypes.ResultValidators, error)
- type Client
- type EventsClient
- type EvidenceClient
- type HTTP
- func (c HTTP) ABCIInfo() (*ctypes.ResultABCIInfo, error)
- func (c HTTP) ABCIQuery(path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error)
- func (c HTTP) ABCIQueryWithOptions(path string, data bytes.HexBytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
- func (c HTTP) Block(height *int64) (*ctypes.ResultBlock, error)
- func (c HTTP) BlockResults(height *int64) (*ctypes.ResultBlockResults, error)
- func (c HTTP) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)
- func (c HTTP) BroadcastEvidence(ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error)
- func (c HTTP) BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- func (c HTTP) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
- func (c HTTP) BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- func (c HTTP) Commit(height *int64) (*ctypes.ResultCommit, error)
- func (c HTTP) ConsensusParams(height *int64) (*ctypes.ResultConsensusParams, error)
- func (c HTTP) ConsensusState() (*ctypes.ResultConsensusState, error)
- func (c HTTP) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error)
- func (c HTTP) Genesis() (*ctypes.ResultGenesis, error)
- func (c HTTP) Health() (*ctypes.ResultHealth, error)
- func (c HTTP) NetInfo() (*ctypes.ResultNetInfo, error)
- func (c *HTTP) NewBatch() *BatchHTTP
- func (c HTTP) NumUnconfirmedTxs() (*ctypes.ResultUnconfirmedTxs, error)
- func (c *HTTP) SetLogger(l log.Logger)
- func (c HTTP) Status() (*ctypes.ResultStatus, error)
- func (c HTTP) Tx(hash []byte, prove bool) (*ctypes.ResultTx, error)
- func (c HTTP) TxSearch(query string, prove bool, page, perPage int, orderBy string) (*ctypes.ResultTxSearch, error)
- func (c HTTP) UnconfirmedTxs(limit int) (*ctypes.ResultUnconfirmedTxs, error)
- func (c HTTP) Validators(height *int64, page, perPage int) (*ctypes.ResultValidators, error)
- type HistoryClient
- type Local
- func (c *Local) ABCIInfo() (*ctypes.ResultABCIInfo, error)
- func (c *Local) ABCIQuery(path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error)
- func (c *Local) ABCIQueryWithOptions(path string, data bytes.HexBytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
- func (c *Local) Block(height *int64) (*ctypes.ResultBlock, error)
- func (c *Local) BlockResults(height *int64) (*ctypes.ResultBlockResults, error)
- func (c *Local) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)
- func (c *Local) BroadcastEvidence(ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error)
- func (c *Local) BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- func (c *Local) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
- func (c *Local) BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- func (c *Local) Commit(height *int64) (*ctypes.ResultCommit, error)
- func (c *Local) ConsensusParams(height *int64) (*ctypes.ResultConsensusParams, error)
- func (c *Local) ConsensusState() (*ctypes.ResultConsensusState, error)
- func (c *Local) DialPeers(peers []string, persistent bool) (*ctypes.ResultDialPeers, error)
- func (c *Local) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error)
- func (c *Local) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error)
- func (c *Local) Genesis() (*ctypes.ResultGenesis, error)
- func (c *Local) Health() (*ctypes.ResultHealth, error)
- func (c *Local) NetInfo() (*ctypes.ResultNetInfo, error)
- func (c *Local) NumUnconfirmedTxs() (*ctypes.ResultUnconfirmedTxs, error)
- func (c *Local) SetLogger(l log.Logger)
- func (c *Local) Status() (*ctypes.ResultStatus, error)
- func (c *Local) Subscribe(ctx context.Context, subscriber, query string, outCapacity ...int) (out <-chan ctypes.ResultEvent, err error)
- func (c *Local) Tx(hash []byte, prove bool) (*ctypes.ResultTx, error)
- func (c *Local) TxSearch(query string, prove bool, page, perPage int, orderBy string) (*ctypes.ResultTxSearch, error)
- func (c *Local) UnconfirmedTxs(limit int) (*ctypes.ResultUnconfirmedTxs, error)
- func (c *Local) Unsubscribe(ctx context.Context, subscriber, query string) error
- func (c *Local) UnsubscribeAll(ctx context.Context, subscriber string) error
- func (c *Local) Validators(height *int64, page, perPage int) (*ctypes.ResultValidators, error)
- type MempoolClient
- type NetworkClient
- type SignClient
- type StatusClient
- type WSEvents
- func (w *WSEvents) OnStart() (err error)
- func (w *WSEvents) OnStop()
- func (w *WSEvents) Subscribe(ctx context.Context, subscriber, query string, outCapacity ...int) (out <-chan ctypes.ResultEvent, err error)
- func (w *WSEvents) Unsubscribe(ctx context.Context, subscriber, query string) error
- func (w *WSEvents) UnsubscribeAll(ctx context.Context, subscriber string) error
- type Waiter
Examples ¶
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 BatchHTTP ¶ added in v0.31.6
type BatchHTTP struct {
// contains filtered or unexported fields
}
BatchHTTP provides the same interface as `HTTP`, but allows for batching of requests (as per https://www.jsonrpc.org/specification#batch). Do not instantiate directly - rather use the HTTP.NewBatch() method to create an instance of this struct.
Batching of HTTP requests is thread-safe in the sense that multiple goroutines can each create their own batches and send them using the same HTTP client. Multiple goroutines could also enqueue transactions in a single batch, but ordering of transactions in the batch cannot be guaranteed in such an example.
func (BatchHTTP) ABCIInfo ¶ added in v0.31.6
func (c BatchHTTP) ABCIInfo() (*ctypes.ResultABCIInfo, error)
func (BatchHTTP) ABCIQueryWithOptions ¶ added in v0.31.6
func (c BatchHTTP) ABCIQueryWithOptions( path string, data bytes.HexBytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
func (BatchHTTP) Block ¶ added in v0.31.6
func (c BatchHTTP) Block(height *int64) (*ctypes.ResultBlock, error)
func (BatchHTTP) BlockResults ¶ added in v0.31.6
func (c BatchHTTP) BlockResults(height *int64) (*ctypes.ResultBlockResults, error)
func (BatchHTTP) BlockchainInfo ¶ added in v0.31.6
func (c BatchHTTP) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)
func (BatchHTTP) BroadcastEvidence ¶ added in v0.32.2
func (c BatchHTTP) BroadcastEvidence(ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error)
func (BatchHTTP) BroadcastTxAsync ¶ added in v0.31.6
func (c BatchHTTP) BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
func (BatchHTTP) BroadcastTxCommit ¶ added in v0.31.6
func (c BatchHTTP) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
func (BatchHTTP) BroadcastTxSync ¶ added in v0.31.6
func (c BatchHTTP) BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
func (*BatchHTTP) Clear ¶ added in v0.31.6
Clear will empty out this batch of requests and return the number of requests that were cleared out.
func (BatchHTTP) Commit ¶ added in v0.31.6
func (c BatchHTTP) Commit(height *int64) (*ctypes.ResultCommit, error)
func (BatchHTTP) ConsensusParams ¶ added in v0.33.0
func (c BatchHTTP) ConsensusParams(height *int64) (*ctypes.ResultConsensusParams, error)
func (BatchHTTP) ConsensusState ¶ added in v0.31.6
func (c BatchHTTP) ConsensusState() (*ctypes.ResultConsensusState, error)
func (*BatchHTTP) Count ¶ added in v0.31.6
Count returns the number of enqueued requests waiting to be sent.
func (BatchHTTP) DumpConsensusState ¶ added in v0.31.6
func (c BatchHTTP) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error)
func (BatchHTTP) Genesis ¶ added in v0.31.6
func (c BatchHTTP) Genesis() (*ctypes.ResultGenesis, error)
func (BatchHTTP) Health ¶ added in v0.31.6
func (c BatchHTTP) Health() (*ctypes.ResultHealth, error)
func (BatchHTTP) NetInfo ¶ added in v0.31.6
func (c BatchHTTP) NetInfo() (*ctypes.ResultNetInfo, error)
func (BatchHTTP) NumUnconfirmedTxs ¶ added in v0.31.6
func (c BatchHTTP) NumUnconfirmedTxs() (*ctypes.ResultUnconfirmedTxs, error)
func (*BatchHTTP) Send ¶ added in v0.31.6
Send is a convenience function for an HTTP batch that will trigger the compilation of the batched requests and send them off using the client as a single request. On success, this returns a list of the deserialized results from each request in the sent batch.
func (BatchHTTP) Status ¶ added in v0.31.6
func (c BatchHTTP) Status() (*ctypes.ResultStatus, error)
func (BatchHTTP) UnconfirmedTxs ¶ added in v0.31.6
func (c BatchHTTP) UnconfirmedTxs(limit int) (*ctypes.ResultUnconfirmedTxs, error)
func (BatchHTTP) Validators ¶ added in v0.31.6
func (c BatchHTTP) Validators(height *int64, page, perPage int) (*ctypes.ResultValidators, error)
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 ¶ added in v0.32.2
type EvidenceClient interface {
BroadcastEvidence(ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error)
}
EvidenceClient is used for submitting an evidence of the malicious behaviour.
type HTTP ¶
type HTTP struct { *WSEvents // contains filtered or unexported fields }
HTTP is a Client implementation that communicates with a Tendermint node over JSON RPC and WebSockets.
This is the main implementation you probably want to use in production code. There are other implementations when calling the Tendermint node in-process (Local), or when you want to mock out the server for test code (mock).
You can subscribe for any event published by Tendermint using Subscribe method. Note delivery is best-effort. If you don't read events fast enough or network is slow, Tendermint might cancel the subscription. The client will attempt to resubscribe (you don't need to do anything). It will keep trying every second indefinitely until successful.
Request batching is available for JSON RPC requests over HTTP, which conforms to the JSON RPC specification (https://www.jsonrpc.org/specification#batch). See the example for more details.
Example (Batching) ¶
package main import ( "fmt" "github.com/tendermint/tendermint/abci/example/kvstore" "github.com/tendermint/tendermint/rpc/client" ctypes "github.com/tendermint/tendermint/rpc/core/types" rpctest "github.com/tendermint/tendermint/rpc/test" ) func main() { // Start a tendermint node (and kvstore) in the background to test against app := kvstore.NewApplication() node := rpctest.StartTendermint(app, rpctest.SuppressStdout, rpctest.RecreateConfig) defer rpctest.StopTendermint(node) // Create our RPC client rpcAddr := rpctest.GetConfig().RPC.ListenAddress c, err := client.NewHTTP(rpcAddr, "/websocket") if err != nil { panic(err) } // Create our two transactions k1 := []byte("firstName") v1 := []byte("satoshi") tx1 := append(k1, append([]byte("="), v1...)...) k2 := []byte("lastName") v2 := []byte("nakamoto") tx2 := append(k2, append([]byte("="), v2...)...) txs := [][]byte{tx1, tx2} // Create a new batch batch := c.NewBatch() // Queue up our transactions for _, tx := range txs { if _, err := batch.BroadcastTxCommit(tx); err != nil { panic(err) } } // Send the batch of 2 transactions if _, err := batch.Send(); err != nil { panic(err) } // Now let's query for the original results as a batch keys := [][]byte{k1, k2} for _, key := range keys { if _, err := batch.ABCIQuery("/key", key); err != nil { panic(err) } } // Send the 2 queries and keep the results results, err := batch.Send() if err != nil { panic(err) } // Each result in the returned list is the deserialized result of each // respective ABCIQuery response for _, result := range results { qr, ok := result.(*ctypes.ResultABCIQuery) if !ok { panic("invalid result type from ABCIQuery request") } fmt.Println(string(qr.Response.Key), "=", string(qr.Response.Value)) } }
Output: firstName = satoshi lastName = nakamoto
Example (Simple) ¶
package main import ( "bytes" "fmt" "github.com/tendermint/tendermint/abci/example/kvstore" "github.com/tendermint/tendermint/rpc/client" rpctest "github.com/tendermint/tendermint/rpc/test" ) func main() { // Start a tendermint node (and kvstore) in the background to test against app := kvstore.NewApplication() node := rpctest.StartTendermint(app, rpctest.SuppressStdout, rpctest.RecreateConfig) defer rpctest.StopTendermint(node) // Create our RPC client rpcAddr := rpctest.GetConfig().RPC.ListenAddress c, err := client.NewHTTP(rpcAddr, "/websocket") if err != nil { panic(err) } // Create a transaction k := []byte("name") v := []byte("satoshi") tx := append(k, append([]byte("="), v...)...) // Broadcast the transaction and wait for it to commit (rather use // c.BroadcastTxSync though in production) bres, err := c.BroadcastTxCommit(tx) if err != nil { panic(err) } if bres.CheckTx.IsErr() || bres.DeliverTx.IsErr() { panic("BroadcastTxCommit transaction failed") } // Now try to fetch the value for the key qres, err := c.ABCIQuery("/key", k) if err != nil { panic(err) } if qres.Response.IsErr() { panic("ABCIQuery failed") } if !bytes.Equal(qres.Response.Key, k) { panic("returned key does not match queried key") } if !bytes.Equal(qres.Response.Value, v) { panic("returned value does not match sent value") } fmt.Println("Sent tx :", string(tx)) fmt.Println("Queried for :", string(qres.Response.Key)) fmt.Println("Got value :", string(qres.Response.Value)) }
Output: Sent tx : name=satoshi Queried for : name Got value : satoshi
func NewHTTP ¶
NewHTTP takes a remote endpoint in the form <protocol>://<host>:<port> and the websocket path (which always seems to be "/websocket") An error is returned on invalid remote. The function panics when remote is nil.
func NewHTTPWithClient ¶ added in v0.32.4
NewHTTPWithClient allows for setting a custom http client (See NewHTTP). An error is returned on invalid remote. The function panics when remote is nil.
func (HTTP) ABCIInfo ¶
func (c HTTP) ABCIInfo() (*ctypes.ResultABCIInfo, error)
func (HTTP) ABCIQueryWithOptions ¶
func (c HTTP) ABCIQueryWithOptions( path string, data bytes.HexBytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
func (HTTP) BlockResults ¶
func (c HTTP) BlockResults(height *int64) (*ctypes.ResultBlockResults, error)
func (HTTP) BlockchainInfo ¶
func (c HTTP) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)
func (HTTP) BroadcastEvidence ¶ added in v0.32.2
func (c HTTP) BroadcastEvidence(ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error)
func (HTTP) BroadcastTxAsync ¶
func (c HTTP) BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
func (HTTP) BroadcastTxCommit ¶
func (c HTTP) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
func (HTTP) BroadcastTxSync ¶
func (c HTTP) BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
func (HTTP) ConsensusParams ¶ added in v0.33.0
func (c HTTP) ConsensusParams(height *int64) (*ctypes.ResultConsensusParams, error)
func (HTTP) ConsensusState ¶
func (c HTTP) ConsensusState() (*ctypes.ResultConsensusState, error)
func (HTTP) DumpConsensusState ¶
func (c HTTP) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error)
func (HTTP) Genesis ¶
func (c HTTP) Genesis() (*ctypes.ResultGenesis, error)
func (HTTP) Health ¶
func (c HTTP) Health() (*ctypes.ResultHealth, error)
func (HTTP) NetInfo ¶
func (c HTTP) NetInfo() (*ctypes.ResultNetInfo, error)
func (HTTP) NumUnconfirmedTxs ¶
func (c HTTP) NumUnconfirmedTxs() (*ctypes.ResultUnconfirmedTxs, error)
func (HTTP) Status ¶
func (c HTTP) Status() (*ctypes.ResultStatus, error)
func (HTTP) UnconfirmedTxs ¶
func (c HTTP) UnconfirmedTxs(limit int) (*ctypes.ResultUnconfirmedTxs, error)
func (HTTP) Validators ¶
func (c HTTP) Validators(height *int64, page, perPage int) (*ctypes.ResultValidators, error)
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 Local ¶
Local is a Client implementation that directly executes the rpc functions on a given node, without going through HTTP or GRPC.
This implementation is useful for:
* Running tests against a node in-process without the overhead of going through an http server * Communication between an ABCI app and Tendermint core when they are compiled in process.
For real clients, you probably want to use client.HTTP. For more powerful control during testing, you probably want the "client/mock" package.
You can subscribe for any event published by Tendermint using Subscribe method. Note delivery is best-effort. If you don't read events fast enough, Tendermint might cancel the subscription. The client will attempt to resubscribe (you don't need to do anything). It will keep trying indefinitely with exponential backoff (10ms -> 20ms -> 40ms) until successful.
func NewLocal ¶
NewLocal configures a client that calls the Node directly.
Note that given how rpc/core works with package singletons, that you can only have one node per process. So make sure test cases don't run in parallel, or try to simulate an entire network in one process...
func (*Local) ABCIQueryWithOptions ¶
func (c *Local) ABCIQueryWithOptions( path string, data bytes.HexBytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
func (*Local) BlockResults ¶
func (c *Local) BlockResults(height *int64) (*ctypes.ResultBlockResults, error)
func (*Local) BlockchainInfo ¶
func (c *Local) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)
func (*Local) BroadcastEvidence ¶ added in v0.32.2
func (*Local) BroadcastTxAsync ¶
func (*Local) BroadcastTxCommit ¶
func (*Local) BroadcastTxSync ¶
func (*Local) ConsensusParams ¶ added in v0.33.0
func (c *Local) ConsensusParams(height *int64) (*ctypes.ResultConsensusParams, error)
func (*Local) ConsensusState ¶
func (c *Local) ConsensusState() (*ctypes.ResultConsensusState, error)
func (*Local) DialSeeds ¶
func (c *Local) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error)
func (*Local) DumpConsensusState ¶
func (c *Local) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error)
func (*Local) NumUnconfirmedTxs ¶
func (c *Local) NumUnconfirmedTxs() (*ctypes.ResultUnconfirmedTxs, error)
func (*Local) UnconfirmedTxs ¶
func (c *Local) UnconfirmedTxs(limit int) (*ctypes.ResultUnconfirmedTxs, error)
func (*Local) Unsubscribe ¶
func (*Local) UnsubscribeAll ¶
func (*Local) Validators ¶
type MempoolClient ¶
type MempoolClient interface { UnconfirmedTxs(limit int) (*ctypes.ResultUnconfirmedTxs, error) NumUnconfirmedTxs() (*ctypes.ResultUnconfirmedTxs, 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.
type WSEvents ¶
type WSEvents struct { service.BaseService // contains filtered or unexported fields }
func (*WSEvents) OnStop ¶
func (w *WSEvents) OnStop()
OnStop implements service.Service by stopping WSClient.
func (*WSEvents) Subscribe ¶
func (w *WSEvents) Subscribe(ctx context.Context, subscriber, query string, outCapacity ...int) (out <-chan ctypes.ResultEvent, err error)
Subscribe implements EventsClient by using WSClient to subscribe given subscriber to query. By default, returns a channel with cap=1. Error is returned if it fails to subscribe. Channel is never closed to prevent clients from seeing an erroneus event.
func (*WSEvents) Unsubscribe ¶
Unsubscribe implements EventsClient by using WSClient to unsubscribe given subscriber from query.