http

package
v0.14.0-dev.4 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

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) ABCIQuery

func (c BatchHTTP) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*coretypes.ResultABCIQuery, error)

func (BatchHTTP) ABCIQueryWithOptions

func (c BatchHTTP) ABCIQueryWithOptions(ctx context.Context, path string, data bytes.HexBytes, opts rpcclient.ABCIQueryOptions) (*coretypes.ResultABCIQuery, error)

func (BatchHTTP) Block

func (c BatchHTTP) Block(ctx context.Context, height *int64) (*coretypes.ResultBlock, error)

func (BatchHTTP) BlockByHash

func (c BatchHTTP) BlockByHash(ctx context.Context, hash bytes.HexBytes) (*coretypes.ResultBlock, error)

func (BatchHTTP) BlockResults

func (c BatchHTTP) BlockResults(ctx context.Context, height *int64) (*coretypes.ResultBlockResults, error)

func (BatchHTTP) BlockSearch

func (c BatchHTTP) BlockSearch(ctx context.Context, query string, page, perPage *int, orderBy string) (*coretypes.ResultBlockSearch, error)

func (BatchHTTP) BlockchainInfo

func (c BatchHTTP) BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*coretypes.ResultBlockchainInfo, error)

func (BatchHTTP) BroadcastEvidence

func (c BatchHTTP) BroadcastEvidence(ctx context.Context, ev types.Evidence) (*coretypes.ResultBroadcastEvidence, error)

func (BatchHTTP) BroadcastTx

func (c BatchHTTP) BroadcastTx(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error)

func (BatchHTTP) BroadcastTxAsync

func (c BatchHTTP) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error)

func (BatchHTTP) BroadcastTxCommit

func (c BatchHTTP) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTxCommit, error)

func (BatchHTTP) BroadcastTxSync

func (c BatchHTTP) BroadcastTxSync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error)

func (BatchHTTP) CheckTx

func (c BatchHTTP) CheckTx(ctx context.Context, tx types.Tx) (*coretypes.ResultCheckTx, error)

func (*BatchHTTP) Clear

func (b *BatchHTTP) Clear() int

Clear will empty out this batch of requests and return the number of requests that were cleared out.

func (BatchHTTP) Commit

func (c BatchHTTP) Commit(ctx context.Context, height *int64) (*coretypes.ResultCommit, error)

func (BatchHTTP) ConsensusParams

func (c BatchHTTP) ConsensusParams(ctx context.Context, height *int64) (*coretypes.ResultConsensusParams, error)

func (BatchHTTP) ConsensusState

func (c BatchHTTP) ConsensusState(ctx context.Context) (*coretypes.ResultConsensusState, error)

func (*BatchHTTP) Count

func (b *BatchHTTP) Count() int

Count returns the number of enqueued requests waiting to be sent.

func (BatchHTTP) DumpConsensusState

func (c BatchHTTP) DumpConsensusState(ctx context.Context) (*coretypes.ResultDumpConsensusState, error)

func (BatchHTTP) Events

func (c BatchHTTP) Events(ctx context.Context, req *coretypes.RequestEvents) (*coretypes.ResultEvents, error)

func (BatchHTTP) Genesis

func (c BatchHTTP) Genesis(ctx context.Context) (*coretypes.ResultGenesis, error)

func (BatchHTTP) GenesisChunked

func (c BatchHTTP) GenesisChunked(ctx context.Context, id uint) (*coretypes.ResultGenesisChunk, error)

func (BatchHTTP) Header

func (c BatchHTTP) Header(ctx context.Context, height *int64) (*coretypes.ResultHeader, error)

func (BatchHTTP) HeaderByHash

func (c BatchHTTP) HeaderByHash(ctx context.Context, hash bytes.HexBytes) (*coretypes.ResultHeader, error)

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) RemoveTx

func (c BatchHTTP) RemoveTx(ctx context.Context, txKey types.TxKey) error

func (*BatchHTTP) Send

func (b *BatchHTTP) Send(ctx context.Context) ([]interface{}, error)

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) Tx

func (c BatchHTTP) Tx(ctx context.Context, hash bytes.HexBytes, prove bool) (*coretypes.ResultTx, error)

func (BatchHTTP) TxSearch

func (c BatchHTTP) TxSearch(ctx context.Context, query string, prove bool, page, perPage *int, orderBy string) (*coretypes.ResultTxSearch, error)

func (BatchHTTP) UnconfirmedTxs

func (c BatchHTTP) UnconfirmedTxs(ctx context.Context, page *int, perPage *int) (*coretypes.ResultUnconfirmedTxs, error)

func (BatchHTTP) Validators

func (c BatchHTTP) Validators(
	ctx context.Context,
	height *int64,
	page, perPage *int,
	requestQuorumInfo *bool,
) (*coretypes.ResultValidators, error)

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

func New(remote string) (*HTTP, error)

New takes a remote endpoint in the form <protocol>://<host>:<port>. An error is returned on invalid remote.

func NewWithClient

func NewWithClient(remote string, c *http.Client) (*HTTP, error)

NewWithClient constructs an RPC client using a custom HTTP client. An error is reported if c == nil or remote is an invalid address.

func NewWithTimeout

func NewWithTimeout(remote string, t time.Duration) (*HTTP, error)

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) ABCIQuery

func (c HTTP) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*coretypes.ResultABCIQuery, error)

func (HTTP) ABCIQueryWithOptions

func (c HTTP) ABCIQueryWithOptions(ctx context.Context, path string, data bytes.HexBytes, opts rpcclient.ABCIQueryOptions) (*coretypes.ResultABCIQuery, error)

func (HTTP) Block

func (c HTTP) Block(ctx context.Context, height *int64) (*coretypes.ResultBlock, error)

func (HTTP) BlockByHash

func (c HTTP) BlockByHash(ctx context.Context, hash bytes.HexBytes) (*coretypes.ResultBlock, error)

func (HTTP) BlockResults

func (c HTTP) BlockResults(ctx context.Context, height *int64) (*coretypes.ResultBlockResults, error)

func (HTTP) BlockSearch

func (c HTTP) BlockSearch(ctx context.Context, query string, page, perPage *int, orderBy string) (*coretypes.ResultBlockSearch, error)

func (HTTP) BlockchainInfo

func (c HTTP) BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*coretypes.ResultBlockchainInfo, error)

func (HTTP) BroadcastEvidence

func (c HTTP) BroadcastEvidence(ctx context.Context, ev types.Evidence) (*coretypes.ResultBroadcastEvidence, error)

func (HTTP) BroadcastTx

func (c HTTP) BroadcastTx(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error)

func (HTTP) BroadcastTxAsync

func (c HTTP) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error)

func (HTTP) BroadcastTxCommit

func (c HTTP) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTxCommit, error)

func (HTTP) BroadcastTxSync

func (c HTTP) BroadcastTxSync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error)

func (HTTP) CheckTx

func (c HTTP) CheckTx(ctx context.Context, tx types.Tx) (*coretypes.ResultCheckTx, error)

func (HTTP) Commit

func (c HTTP) Commit(ctx context.Context, height *int64) (*coretypes.ResultCommit, error)

func (HTTP) ConsensusParams

func (c HTTP) ConsensusParams(ctx context.Context, height *int64) (*coretypes.ResultConsensusParams, error)

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) Events

func (c HTTP) Events(ctx context.Context, req *coretypes.RequestEvents) (*coretypes.ResultEvents, error)

func (HTTP) Genesis

func (c HTTP) Genesis(ctx context.Context) (*coretypes.ResultGenesis, error)

func (HTTP) GenesisChunked

func (c HTTP) GenesisChunked(ctx context.Context, id uint) (*coretypes.ResultGenesisChunk, error)

func (HTTP) Header

func (c HTTP) Header(ctx context.Context, height *int64) (*coretypes.ResultHeader, error)

func (HTTP) HeaderByHash

func (c HTTP) HeaderByHash(ctx context.Context, hash bytes.HexBytes) (*coretypes.ResultHeader, error)

func (HTTP) Health

func (c HTTP) Health(ctx context.Context) (*coretypes.ResultHealth, error)

func (HTTP) NetInfo

func (c HTTP) NetInfo(ctx context.Context) (*coretypes.ResultNetInfo, error)

func (*HTTP) NewBatch

func (c *HTTP) NewBatch() *BatchHTTP

NewBatch creates a new batch client for this HTTP client.

func (HTTP) NumUnconfirmedTxs

func (c HTTP) NumUnconfirmedTxs(ctx context.Context) (*coretypes.ResultUnconfirmedTxs, error)

func (*HTTP) Remote

func (c *HTTP) Remote() string

Remote returns the remote network address in a string form.

func (HTTP) RemoveTx

func (c HTTP) RemoveTx(ctx context.Context, txKey types.TxKey) error

func (HTTP) Start

func (w HTTP) Start(ctx context.Context) error

Start starts the websocket client and the event loop.

func (HTTP) Status

func (c HTTP) Status(ctx context.Context) (*coretypes.ResultStatus, error)

func (HTTP) Stop

func (w HTTP) Stop() error

Stop shuts down the websocket client.

func (HTTP) Subscribe

func (w HTTP) Subscribe(ctx context.Context, _subscriber, query string,
	outCapacity ...int) (out <-chan coretypes.ResultEvent, err error)

Subscribe implements SubscriptionClient 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) Tx

func (c HTTP) Tx(ctx context.Context, hash bytes.HexBytes, prove bool) (*coretypes.ResultTx, error)

func (HTTP) TxSearch

func (c HTTP) TxSearch(ctx context.Context, query string, prove bool, page, perPage *int, orderBy string) (*coretypes.ResultTxSearch, error)

func (HTTP) UnconfirmedTxs

func (c HTTP) UnconfirmedTxs(ctx context.Context, page *int, perPage *int) (*coretypes.ResultUnconfirmedTxs, error)

func (HTTP) Unsubscribe

func (w HTTP) Unsubscribe(ctx context.Context, _subscriber, query string) error

Unsubscribe implements SubscriptionClient by using WSClient to unsubscribe given subscriber from query.

It returns an error if wsEvents is not running.

func (HTTP) UnsubscribeAll

func (w HTTP) UnsubscribeAll(ctx context.Context, _subscriber string) error

UnsubscribeAll implements SubscriptionClient by using WSClient to unsubscribe given subscriber from all the queries.

It returns an error if wsEvents is not running.

func (HTTP) Validators

func (c HTTP) Validators(
	ctx context.Context,
	height *int64,
	page, perPage *int,
	requestQuorumInfo *bool,
) (*coretypes.ResultValidators, error)

Jump to

Keyboard shortcuts

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