client

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package client simplifies communication with the blockchain application

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrReconnectFailure indicates error due to inability to reconnect to any specified node.
	ErrReconnectFailure = errors.New("could not reconnect to any node")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client encapsulates all necessary data for communicating with the blockchain application by possibly multiple clients simultaneously.

func New

func New(nodeAddresses []string, logger *logger.Logger) (*Client, error)

New returns new instance of the client

func (*Client) BlockResults

func (c *Client) BlockResults(height *int64) (*ctypes.ResultBlockResults, error)

BlockResults results from a block at given height. If no height is provided, most recent block is queried

func (*Client) BlockchainInfo

func (c *Client) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)

BlockchainInfo return block headers from the specified range. Note: according to the docs it can only return up to 20 results.

func (*Client) Broadcast

func (c *Client) Broadcast(tx []byte) (*ctypes.ResultBroadcastTxCommit, error)

Broadcast sends a transaction to specified blockchain nodes and waits until it is included on the chain.

func (*Client) ForceReconnect

func (c *Client) ForceReconnect() error

ForceReconnect tries to force the client to reconnect to one of the blockchain nodes.

func (*Client) Query

func (c *Client) Query(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error)

Query sends a query to specified blockchain node at given path. Note that it just returns state information (that might be stale) and is NOT included in transactions.

func (*Client) SendAsync

func (c *Client) SendAsync(tx []byte) (*ctypes.ResultBroadcastTx, error)

SendAsync sends an async transaction to specified blockchain node. Note that there is no guarantee the transaction was included on the chain (it might not have been even added to the mempool because it could have failed CheckTx)

func (*Client) SendSync

func (c *Client) SendSync(tx []byte) (*ctypes.ResultBroadcastTx, error)

SendSync sends an sync transaction to specified blockchain node. Note that there is no guarantee the transaction succeeded, but it definitely passed CheckTx and was included in the mempool. However, it still might return an error at DeliverTx.

func (*Client) Stop

func (c *Client) Stop()

Stop gracefully stops the client

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, subscriber, query string,
	outCapacity ...int) (out <-chan ctypes.ResultEvent, err error)

Subscribe is a wrapper for the websocket subscribe method.

func (*Client) TxByHash

func (c *Client) TxByHash(hash cmn.HexBytes) (*ctypes.ResultTx, error)

TxByHash queries the chain to get particular tx results given its hash.

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(ctx context.Context, subscriber, query string) error

Unsubscribe is a wrapper for the websocket unsubscribe method.

func (*Client) UnsubscribeAll

func (c *Client) UnsubscribeAll(ctx context.Context, subscriber string) error

UnsubscribeAll is a wrapper for the websocket unsubscribeAll method.

Jump to

Keyboard shortcuts

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