Documentation ¶
Index ¶
- type BatchHTTP
- func (c BatchHTTP) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error)
- func (c BatchHTTP) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*coretypes.ResultABCIQuery, error)
- func (c BatchHTTP) ABCIQueryWithOptions(ctx context.Context, path string, data bytes.HexBytes, ...) (*coretypes.ResultABCIQuery, error)
- func (c BatchHTTP) Block(ctx context.Context, height *int64) (*coretypes.ResultBlock, error)
- func (c BatchHTTP) BlockByHash(ctx context.Context, hash bytes.HexBytes) (*coretypes.ResultBlock, error)
- func (c BatchHTTP) BlockResults(ctx context.Context, height *int64) (*coretypes.ResultBlockResults, error)
- func (c BatchHTTP) BlockSearch(ctx context.Context, query string, page, perPage *int, orderBy string) (*coretypes.ResultBlockSearch, error)
- func (c BatchHTTP) BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*coretypes.ResultBlockchainInfo, error)
- func (c BatchHTTP) BroadcastEvidence(ctx context.Context, ev types.Evidence) (*coretypes.ResultBroadcastEvidence, error)
- func (c BatchHTTP) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error)
- func (c BatchHTTP) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTxCommit, error)
- func (c BatchHTTP) BroadcastTxSync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error)
- func (c BatchHTTP) CheckTx(ctx context.Context, tx types.Tx) (*coretypes.ResultCheckTx, error)
- func (b *BatchHTTP) Clear() int
- func (c BatchHTTP) Commit(ctx context.Context, height *int64) (*coretypes.ResultCommit, error)
- func (c BatchHTTP) ConsensusParams(ctx context.Context, height *int64) (*coretypes.ResultConsensusParams, error)
- func (c BatchHTTP) ConsensusState(ctx context.Context) (*coretypes.ResultConsensusState, error)
- func (b *BatchHTTP) Count() int
- func (c BatchHTTP) DumpConsensusState(ctx context.Context) (*coretypes.ResultDumpConsensusState, error)
- func (c BatchHTTP) Genesis(ctx context.Context) (*coretypes.ResultGenesis, error)
- func (c BatchHTTP) GenesisChunked(ctx context.Context, id uint) (*coretypes.ResultGenesisChunk, error)
- func (c BatchHTTP) Health(ctx context.Context) (*coretypes.ResultHealth, error)
- func (c BatchHTTP) NetInfo(ctx context.Context) (*coretypes.ResultNetInfo, error)
- func (c BatchHTTP) NumUnconfirmedTxs(ctx context.Context) (*coretypes.ResultUnconfirmedTxs, error)
- func (b *BatchHTTP) Send(ctx context.Context) ([]interface{}, error)
- func (c BatchHTTP) Status(ctx context.Context) (*coretypes.ResultStatus, error)
- func (c BatchHTTP) Tx(ctx context.Context, hash bytes.HexBytes, prove bool) (*coretypes.ResultTx, error)
- func (c BatchHTTP) TxSearch(ctx context.Context, query string, prove bool, page, perPage *int, ...) (*coretypes.ResultTxSearch, error)
- func (c BatchHTTP) UnconfirmedTxs(ctx context.Context, limit *int) (*coretypes.ResultUnconfirmedTxs, error)
- func (c BatchHTTP) Validators(ctx context.Context, height *int64, page, perPage *int) (*coretypes.ResultValidators, error)
- type HTTP
- func (c HTTP) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error)
- func (c HTTP) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*coretypes.ResultABCIQuery, error)
- func (c HTTP) ABCIQueryWithOptions(ctx context.Context, path string, data bytes.HexBytes, ...) (*coretypes.ResultABCIQuery, error)
- func (c HTTP) Block(ctx context.Context, height *int64) (*coretypes.ResultBlock, error)
- func (c HTTP) BlockByHash(ctx context.Context, hash bytes.HexBytes) (*coretypes.ResultBlock, error)
- func (c HTTP) BlockResults(ctx context.Context, height *int64) (*coretypes.ResultBlockResults, error)
- func (c HTTP) BlockSearch(ctx context.Context, query string, page, perPage *int, orderBy string) (*coretypes.ResultBlockSearch, error)
- func (c HTTP) BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*coretypes.ResultBlockchainInfo, error)
- func (c HTTP) BroadcastEvidence(ctx context.Context, ev types.Evidence) (*coretypes.ResultBroadcastEvidence, error)
- func (c HTTP) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error)
- func (c HTTP) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTxCommit, error)
- func (c HTTP) BroadcastTxSync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error)
- func (c HTTP) CheckTx(ctx context.Context, tx types.Tx) (*coretypes.ResultCheckTx, error)
- func (c HTTP) Commit(ctx context.Context, height *int64) (*coretypes.ResultCommit, error)
- func (c HTTP) ConsensusParams(ctx context.Context, height *int64) (*coretypes.ResultConsensusParams, error)
- func (c HTTP) ConsensusState(ctx context.Context) (*coretypes.ResultConsensusState, error)
- func (c HTTP) DumpConsensusState(ctx context.Context) (*coretypes.ResultDumpConsensusState, error)
- func (c HTTP) Genesis(ctx context.Context) (*coretypes.ResultGenesis, error)
- func (c HTTP) GenesisChunked(ctx context.Context, id uint) (*coretypes.ResultGenesisChunk, error)
- func (c HTTP) Health(ctx context.Context) (*coretypes.ResultHealth, error)
- func (w HTTP) IsRunning() bool
- func (c HTTP) NetInfo(ctx context.Context) (*coretypes.ResultNetInfo, error)
- func (c *HTTP) NewBatch() *BatchHTTP
- func (c HTTP) NumUnconfirmedTxs(ctx context.Context) (*coretypes.ResultUnconfirmedTxs, error)
- func (c *HTTP) Remote() string
- func (w HTTP) Start() error
- func (c HTTP) Status(ctx context.Context) (*coretypes.ResultStatus, error)
- func (w HTTP) Stop() error
- func (w HTTP) Subscribe(ctx context.Context, subscriber, query string, outCapacity ...int) (out <-chan coretypes.ResultEvent, err error)
- func (c HTTP) Tx(ctx context.Context, hash bytes.HexBytes, prove bool) (*coretypes.ResultTx, error)
- func (c HTTP) TxSearch(ctx context.Context, query string, prove bool, page, perPage *int, ...) (*coretypes.ResultTxSearch, error)
- func (c HTTP) UnconfirmedTxs(ctx context.Context, limit *int) (*coretypes.ResultUnconfirmedTxs, error)
- func (w HTTP) Unsubscribe(ctx context.Context, subscriber, query string) error
- func (w HTTP) UnsubscribeAll(ctx context.Context, subscriber string) error
- func (c HTTP) Validators(ctx context.Context, height *int64, page, perPage *int) (*coretypes.ResultValidators, error)
- type WSOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchHTTP ¶
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 ¶
func (c BatchHTTP) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error)
func (BatchHTTP) ABCIQueryWithOptions ¶
func (c BatchHTTP) ABCIQueryWithOptions( ctx context.Context, path string, data bytes.HexBytes, opts rpcclient.ABCIQueryOptions) (*coretypes.ResultABCIQuery, error)
func (BatchHTTP) BlockByHash ¶ added in v0.34.0
func (BatchHTTP) BlockResults ¶
func (BatchHTTP) BlockSearch ¶ added in v0.34.9
func (BatchHTTP) BlockchainInfo ¶
func (BatchHTTP) BroadcastEvidence ¶
func (BatchHTTP) BroadcastTxAsync ¶
func (BatchHTTP) BroadcastTxCommit ¶
func (BatchHTTP) BroadcastTxSync ¶
func (*BatchHTTP) Clear ¶
Clear will empty out this batch of requests and return the number of requests that were cleared out.
func (BatchHTTP) ConsensusParams ¶
func (BatchHTTP) ConsensusState ¶
func (c BatchHTTP) ConsensusState(ctx context.Context) (*coretypes.ResultConsensusState, error)
func (BatchHTTP) DumpConsensusState ¶
func (c BatchHTTP) DumpConsensusState(ctx context.Context) (*coretypes.ResultDumpConsensusState, error)
func (BatchHTTP) Genesis ¶
func (c BatchHTTP) Genesis(ctx context.Context) (*coretypes.ResultGenesis, error)
func (BatchHTTP) GenesisChunked ¶ added in v0.34.12
func (BatchHTTP) Health ¶
func (c BatchHTTP) Health(ctx context.Context) (*coretypes.ResultHealth, error)
func (BatchHTTP) NetInfo ¶
func (c BatchHTTP) NetInfo(ctx context.Context) (*coretypes.ResultNetInfo, error)
func (BatchHTTP) NumUnconfirmedTxs ¶
func (c BatchHTTP) NumUnconfirmedTxs(ctx context.Context) (*coretypes.ResultUnconfirmedTxs, error)
func (*BatchHTTP) Send ¶
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 ¶
func (c BatchHTTP) Status(ctx context.Context) (*coretypes.ResultStatus, error)
func (BatchHTTP) UnconfirmedTxs ¶
func (BatchHTTP) Validators ¶
type HTTP ¶
type HTTP struct {
// 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:
c, err := New("http://192.168.1.10:26657") if err != nil { // handle error } // call Start/Stop if you're subscribing to events err = c.Start() if err != nil { // handle error } defer c.Stop() res, err := c.Status() if err != nil { // handle error } // handle result
func New ¶
New takes a remote endpoint in the form <protocol>://<host>:<port>. An error is returned on invalid remote.
func NewWithClient ¶
NewWithClient allows you to set a custom http client. An error is returned on invalid remote. The function panics when client is nil.
func NewWithClientAndWSOptions ¶ added in v0.35.0
NewWithClientAndWSOptions allows you to set a custom http client and WebSocket options. An error is returned on invalid remote. The function panics when client is nil.
func NewWithTimeout ¶
NewWithTimeout does the same thing as New, except you can set a Timeout for http.Client. A Timeout of zero means no timeout.
func (HTTP) ABCIInfo ¶
func (c HTTP) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error)
func (HTTP) ABCIQueryWithOptions ¶
func (c HTTP) ABCIQueryWithOptions( ctx context.Context, path string, data bytes.HexBytes, opts rpcclient.ABCIQueryOptions) (*coretypes.ResultABCIQuery, error)
func (HTTP) BlockByHash ¶ added in v0.34.0
func (HTTP) BlockResults ¶
func (HTTP) BlockSearch ¶ added in v0.34.9
func (HTTP) BlockchainInfo ¶
func (HTTP) BroadcastEvidence ¶
func (HTTP) BroadcastTxAsync ¶
func (HTTP) BroadcastTxCommit ¶
func (HTTP) BroadcastTxSync ¶
func (HTTP) ConsensusParams ¶
func (HTTP) ConsensusState ¶
func (c HTTP) ConsensusState(ctx context.Context) (*coretypes.ResultConsensusState, error)
func (HTTP) DumpConsensusState ¶
func (c HTTP) DumpConsensusState(ctx context.Context) (*coretypes.ResultDumpConsensusState, error)
func (HTTP) GenesisChunked ¶ added in v0.34.12
func (HTTP) IsRunning ¶ added in v0.35.0
func (w HTTP) IsRunning() bool
IsRunning reports whether the websocket client is running.
func (HTTP) NumUnconfirmedTxs ¶
func (c HTTP) NumUnconfirmedTxs(ctx context.Context) (*coretypes.ResultUnconfirmedTxs, error)
func (HTTP) Start ¶ added in v0.35.0
func (w HTTP) Start() error
Start starts the websocket client and the event loop.
func (HTTP) Stop ¶ added in v0.35.0
func (w HTTP) Stop() error
Stop shuts down the websocket client.
func (HTTP) Subscribe ¶ added in v0.35.0
func (w HTTP) Subscribe(ctx context.Context, subscriber, query string, outCapacity ...int) (out <-chan coretypes.ResultEvent, err error)
Subscribe implements EventsClient by using WSClient to subscribe given subscriber to query. By default, it returns a channel with cap=1. Error is returned if it fails to subscribe.
When reading from the channel, keep in mind there's a single events loop, so if you don't read events for this subscription fast enough, other subscriptions will slow down in effect.
The channel is never closed to prevent clients from seeing an erroneous event.
It returns an error if wsEvents is not running.
func (HTTP) UnconfirmedTxs ¶
func (HTTP) Unsubscribe ¶ added in v0.35.0
Unsubscribe implements EventsClient by using WSClient to unsubscribe given subscriber from query.
It returns an error if wsEvents is not running.
func (HTTP) UnsubscribeAll ¶ added in v0.35.0
UnsubscribeAll implements EventsClient by using WSClient to unsubscribe given subscriber from all the queries.
It returns an error if wsEvents is not running.
func (HTTP) Validators ¶
type WSOptions ¶ added in v0.35.0
type WSOptions struct { Path string // path (e.g. "/ws") jsonrpcclient.WSOptions // WSClient options }
WSOptions for the WS part of the HTTP client.
func DefaultWSOptions ¶ added in v0.35.0
func DefaultWSOptions() WSOptions
DefaultWSOptions returns default WS options. See jsonrpcclient.DefaultWSOptions.