Documentation ¶
Index ¶
- Variables
- func NewHTTPConnection(remote string) rpcclient.Client
- func NewLocalConnection(node *nm.Node) rpcclient.Client
- func QueryForHeader() string
- func TestWithTendermint(app types.Application, cb func(*nm.Node), m Runner) int
- type Client
- func (c *Client) CommitTx(ctx context.Context, tx weave.Tx) (*CommitResult, error)
- func (c *Client) CommitTxs(ctx context.Context, txs []weave.Tx) ([]*CommitResult, error)
- func (c *Client) GetTxByID(ctx context.Context, id TransactionID) (*CommitResult, error)
- func (c *Client) Header(ctx context.Context, height int64) (*Header, error)
- func (c *Client) Query(query RequestQuery) ResponseQuery
- func (c *Client) SearchTx(ctx context.Context, query TxQuery) ([]*CommitResult, error)
- func (c *Client) Status(ctx context.Context) (*Status, error)
- func (c *Client) SubmitTx(ctx context.Context, tx weave.Tx) (TransactionID, error)
- func (c *Client) SubscribeHeaders(ctx context.Context, results chan<- Header, options ...Option) error
- func (c *Client) SubscribeTx(ctx context.Context, query TxQuery, results chan<- CommitResult, ...) error
- func (c *Client) SubscribeTxByID(ctx context.Context, id TransactionID) (*CommitResult, error)
- func (c *Client) WaitForHeight(ctx context.Context, height int64) (*Header, error)
- func (c *Client) WaitForNextBlock(ctx context.Context) (*Header, error)
- func (c *Client) WatchTx(ctx context.Context, id TransactionID) (*CommitResult, error)
- func (c *Client) WatchTxs(ctx context.Context, ids []TransactionID) ([]*CommitResult, error)
- type CommitResult
- type GenesisDoc
- type Header
- type Option
- type OptionCapacity
- type RequestQuery
- type ResponseQuery
- type Runner
- type Status
- type TransactionID
- type TxQuery
Constants ¶
This section is empty.
Variables ¶
var QueryNewBlockHeader = tmtypes.EventQueryNewBlockHeader
Functions ¶
func NewHTTPConnection ¶
NewHTTPConnection takes a URL and sends all requests to the remote node
func NewLocalConnection ¶
NewLocalConnection wraps an in-process node with a client, useful for tests
func QueryForHeader ¶
func QueryForHeader() string
QueryForHeader is a subscription query for all new headers
func TestWithTendermint ¶
TestWithTendermint provides adaptive startup capabilities and allows supplying a callback to initialize test resources dependent on tendermint node
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a tendermint client wrapped to provide simple access to the basic data structures used in weave
Basic accessors are declared here. Higher-level API build around these basic accessors is defined on another level
func NewLocalClient ¶
NewLocalClient is simply a shorthand for a client with local connection
func (*Client) CommitTx ¶
CommitTx will block on both Check and Deliver, returning when it is in a block
func (*Client) CommitTxs ¶
CommitTxs will submit many transactions and wait until they are all included in blocks. Ideally, all in the same block.
If any tx fails in mempool or network, this returns an error TODO: improve error handling (maybe we need to use CommitResultOrError type?)
func (*Client) GetTxByID ¶
func (c *Client) GetTxByID(ctx context.Context, id TransactionID) (*CommitResult, error)
GetTxByID will return 0 or 1 results (nil or result value)
func (*Client) Header ¶
Header returns the block header at the given height. Returns an error if no header exists yet for that height
func (*Client) Query ¶
func (c *Client) Query(query RequestQuery) ResponseQuery
Query is meant to mirror the abci query interface exactly, so we can wrap it with app.ABCIStore This will give us state from the application
TODO: provide other Query interface that accepts context for timeout??
func (*Client) SearchTx ¶
SearchTx will search for all committed transactions that match a query, returning them as one large array. It returns an error if the subscription request failed.
func (*Client) Status ¶
Status returns current height and other (subjective) status info from this node
func (*Client) SubmitTx ¶
SubmitTx will submit the tx to the mempool and then return with success or error You will need to use WatchTx (easily parallelizable) to get the result. CommitTx and CommitTxs provide helpers for common use cases
func (*Client) SubscribeHeaders ¶
func (c *Client) SubscribeHeaders(ctx context.Context, results chan<- Header, options ...Option) error
SubscribeHeaders will fills the channel with all new headers Stops when the context is cancelled
func (*Client) SubscribeTx ¶
func (c *Client) SubscribeTx(ctx context.Context, query TxQuery, results chan<- CommitResult, options ...Option) error
SubscribeTx will subscribe to all transactions that match a query, writing them to the results channel as they arrive. It returns an error if the subscription request failed. Once subscriptions start, the continue until the context is closed (or network error)
func (*Client) SubscribeTxByID ¶
func (c *Client) SubscribeTxByID(ctx context.Context, id TransactionID) (*CommitResult, error)
SubscribeTxByID will block until there is a result, then return it You must cancel the context to avoid blocking forever in some cases
func (*Client) WaitForHeight ¶
WaitForHeight subscribes to headers and returns as soon as a header arrives equal to or greater than the given height. If the requested height is in the past, it will still wait for the next block to arrive
func (*Client) WaitForNextBlock ¶
WaitForNextBlock will return the next block header to arrive (as subscription)
func (*Client) WatchTx ¶
func (c *Client) WatchTx(ctx context.Context, id TransactionID) (*CommitResult, error)
WatchTx will block until this transaction makes it into a block It will return immediately if the id was included in a block prior to the query, to avoid timing issues You can use context.Context to pass in a timeout
func (*Client) WatchTxs ¶
func (c *Client) WatchTxs(ctx context.Context, ids []TransactionID) ([]*CommitResult, error)
WatchTxs will watch a list of transactions in parallel
type CommitResult ¶
type CommitResult struct { ID TransactionID Height int64 Result *weave.DeliverResult Err error }
CommitResult is returned from the block (DeliverTx) Result is only set on success codes, Err is set if it was a failure code
type GenesisDoc ¶
type GenesisDoc = tmtypes.GenesisDoc
GenesisDoc is the full tendermint genesis file
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option represents an option supplied to subscription
type OptionCapacity ¶
type OptionCapacity struct {
Capacity int
}
OptionCapacity is used for setting channel outCapacity for subscriptions
type RequestQuery ¶
type RequestQuery = abci.RequestQuery
RequestQuery is used for the query interface to mirror the abci query interface
type ResponseQuery ¶
type ResponseQuery = abci.ResponseQuery
ResponseQuery is used for the query interface to mirror the abci query interface
type Runner ¶
type Runner interface {
Run() int
}
Runner is an interface that would allow us more flexibility in terms of types passed to the helper
type Status ¶
Status is the current status of the node we connect to. Latest block height is a useful info
type TransactionID ¶
TransactionID is the hash used to identify the transaction
type TxQuery ¶
type TxQuery = string
TxQuery is some query to find transactions
func QueryTxByID ¶
func QueryTxByID(id TransactionID) TxQuery
QueryTxByID makes a subscription string based on the transaction id