Documentation ¶
Index ¶
- Variables
- type Client
- type Context
- type ErrNetAddressInvalid
- type ErrNetAddressLookup
- type ErrNetAddressNoID
- type EventName
- type EventsClient
- type JSONRPCIntID
- type JSONRPCStringID
- type NewTypedEventParser
- func (p *NewTypedEventParser) Event() string
- func (p *NewTypedEventParser) EventWithFieldName(protoFieldName string) string
- func (p *NewTypedEventParser) SetProtoField(protoFieldName string)
- func (p *NewTypedEventParser) SetProtoMsg(protoMsgName string)
- func (p *NewTypedEventParser) SetProtoPkg(protoPkgName string)
- type NodeID
- type NodeInfo
- type NodeInfoOther
- type Peer
- type ProtocolVersion
- type RPCError
- type RPCRequest
- type RPCResponse
- func NewRPCErrorResponse(id jsonrpcid, code int, msg string, data string) RPCResponse
- func NewRPCSuccessResponse(id jsonrpcid, res interface{}) RPCResponse
- func RPCInternalError(id jsonrpcid, err error) RPCResponse
- func RPCInvalidParamsError(id jsonrpcid, err error) RPCResponse
- func RPCInvalidRequestError(id jsonrpcid, err error) RPCResponse
- func RPCMethodNotFoundError(id jsonrpcid) RPCResponse
- func RPCParseError(err error) RPCResponse
- func RPCServerError(id jsonrpcid, err error) RPCResponse
- type ResultABCIInfo
- type ResultABCIQuery
- type ResultBlock
- type ResultBlockResults
- type ResultBlockSearch
- type ResultBlockchainInfo
- type ResultBroadcastEvidence
- type ResultBroadcastTx
- type ResultBroadcastTxCommit
- type ResultCheckTx
- type ResultCommit
- type ResultDialPeers
- type ResultDialSeeds
- type ResultEvent
- type ResultHeader
- type ResultHealth
- type ResultNetInfo
- type ResultStatus
- type ResultSubscribe
- type ResultTx
- type ResultTxSearch
- type ResultUnconfirmedTxs
- type ResultUnsafeFlushMempool
- type ResultUnsafeProfile
- type ResultUnsubscribe
- type ResultValidators
- type RunState
- type SyncInfo
- type TmEvents
- type ValidatorInfo
- type WSClient
- func (c *WSClient) Call(ctx context.Context, method string, params map[string]interface{}) error
- func (c *WSClient) CallWithArrayParams(ctx context.Context, method string, params []interface{}) error
- func (c *WSClient) IsActive() bool
- func (c *WSClient) IsReconnecting() bool
- func (c *WSClient) OnReconnect(cb func())
- func (c *WSClient) Send(ctx context.Context, request RPCRequest) error
- func (c *WSClient) Start() error
- func (c *WSClient) Stop() error
- func (c *WSClient) String() string
- func (c *WSClient) Subscribe(ctx context.Context, query string) error
- func (c *WSClient) Unsubscribe(ctx context.Context, query string) error
- func (c *WSClient) UnsubscribeAll(ctx context.Context) error
- type WSOptions
- type WSRPCConnection
Constants ¶
This section is empty.
Variables ¶
var ( ErrClientRunning = errors.New("client already running") ErrClientNotRunning = errors.New("client is not running") )
var (
ErrInvalidRequest = errors.New("invalid request")
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Start() error Stop() error IsRunning() bool EventsClient }
Client describes the interface of Tendermint RPC client implementations.
type Context ¶
type Context struct { // json-rpc request JSONReq *RPCRequest // websocket connection WSConn WSRPCConnection // http request HTTPReq *http.Request }
Context is the first parameter for all functions. It carries a json-rpc request, http request and websocket connection.
- JSONReq is non-nil when JSONRPC is called over websocket or HTTP. - WSConn is non-nil when we're connected via a websocket. - HTTPReq is non-nil when URI or JSONRPC is called over HTTP.
func (*Context) Context ¶
Context returns the request's context. The returned context is always non-nil; it defaults to the background context. HTTP:
The context is canceled when the client's connection closes, the request is canceled (with HTTP/2), or when the ServeHTTP method returns.
WS:
The context is canceled when the client's connections closes.
func (*Context) RemoteAddr ¶
RemoteAddr returns the remote address (usually a string "IP:port"). If neither HTTPReq nor WSConn is set, an empty string is returned. HTTP:
http.Request#RemoteAddr
WS:
result of GetRemoteAddr
type ErrNetAddressInvalid ¶
func (ErrNetAddressInvalid) Error ¶
func (e ErrNetAddressInvalid) Error() string
type ErrNetAddressLookup ¶
func (ErrNetAddressLookup) Error ¶
func (e ErrNetAddressLookup) Error() string
type ErrNetAddressNoID ¶
type ErrNetAddressNoID struct {
Addr string
}
func (ErrNetAddressNoID) Error ¶
func (e ErrNetAddressNoID) Error() string
type EventsClient ¶
type EventsClient interface { Subscribe(ctx context.Context, query string) error Unsubscribe(ctx context.Context, query string) error // UnsubscribeAll unsubscribes from all the queries. UnsubscribeAll(ctx context.Context) error }
EventsClient is reactive, you can subscribe to any message, given the proper string.
type JSONRPCIntID ¶
type JSONRPCIntID int
JSONRPCIntID a wrapper for JSON-RPC integer IDs
func (JSONRPCIntID) String ¶
func (id JSONRPCIntID) String() string
type JSONRPCStringID ¶
type JSONRPCStringID string
JSONRPCStringID a wrapper for JSON-RPC string IDs
func (JSONRPCStringID) String ¶
func (id JSONRPCStringID) String() string
type NewTypedEventParser ¶
type NewTypedEventParser struct {
// contains filtered or unexported fields
}
func (*NewTypedEventParser) Event ¶
func (p *NewTypedEventParser) Event() string
func (*NewTypedEventParser) EventWithFieldName ¶
func (p *NewTypedEventParser) EventWithFieldName(protoFieldName string) string
func (*NewTypedEventParser) SetProtoField ¶
func (p *NewTypedEventParser) SetProtoField(protoFieldName string)
func (*NewTypedEventParser) SetProtoMsg ¶
func (p *NewTypedEventParser) SetProtoMsg(protoMsgName string)
func (*NewTypedEventParser) SetProtoPkg ¶
func (p *NewTypedEventParser) SetProtoPkg(protoPkgName string)
type NodeInfo ¶
type NodeInfo struct { ProtocolVersion ProtocolVersion `json:"protocol_version"` // Authenticate NodeID NodeID `json:"id"` // authenticated identifier ListenAddr string `json:"listen_addr"` // accepting incoming // Check compatibility. // Channels are HexBytes so easier to read as JSON Network string `json:"network"` // network/chain ID Version string `json:"version"` // major.minor.revision Channels bytes.HexBytes `json:"channels"` // channels this node knows about // ASCIIText fields Moniker string `json:"moniker"` // arbitrary moniker Other NodeInfoOther `json:"other"` // other application specific data }
NodeInfo is the basic node information exchanged between two peers during the Tendermint P2P handshake.
type NodeInfoOther ¶
type NodeInfoOther struct { TxIndex string `json:"tx_index"` RPCAddress string `json:"rpc_address"` }
NodeInfoOther is the misc. applcation specific data
type ProtocolVersion ¶
type ProtocolVersion struct { P2P uint64 `json:"p2p"` Block uint64 `json:"block"` App uint64 `json:"app"` }
ProtocolVersion contains the protocol versions for the software.
type RPCError ¶
type RPCRequest ¶
type RPCRequest struct { JSONRPC string `json:"jsonrpc"` ID jsonrpcid `json:"id,omitempty"` Method string `json:"method"` Params json.RawMessage `json:"params"` // must be map[string]interface{} or []interface{} }
func ArrayToRequest ¶
func ArrayToRequest(id jsonrpcid, method string, params []interface{}) (RPCRequest, error)
func MapToRequest ¶
func MapToRequest(id jsonrpcid, method string, params map[string]interface{}) (RPCRequest, error)
func NewRPCRequest ¶
func NewRPCRequest(id jsonrpcid, method string, params json.RawMessage) RPCRequest
func (*RPCRequest) String ¶
func (req *RPCRequest) String() string
func (*RPCRequest) UnmarshalJSON ¶
func (req *RPCRequest) UnmarshalJSON(data []byte) error
UnmarshalJSON custom JSON unmarshaling due to jsonrpcid being string or int
type RPCResponse ¶
type RPCResponse struct { JSONRPC string `json:"jsonrpc"` ID jsonrpcid `json:"id,omitempty"` Result json.RawMessage `json:"result,omitempty"` Error *RPCError `json:"error,omitempty"` }
func NewRPCErrorResponse ¶
func NewRPCErrorResponse(id jsonrpcid, code int, msg string, data string) RPCResponse
func NewRPCSuccessResponse ¶
func NewRPCSuccessResponse(id jsonrpcid, res interface{}) RPCResponse
func RPCInternalError ¶
func RPCInternalError(id jsonrpcid, err error) RPCResponse
func RPCInvalidParamsError ¶
func RPCInvalidParamsError(id jsonrpcid, err error) RPCResponse
func RPCInvalidRequestError ¶
func RPCInvalidRequestError(id jsonrpcid, err error) RPCResponse
func RPCMethodNotFoundError ¶
func RPCMethodNotFoundError(id jsonrpcid) RPCResponse
func RPCParseError ¶
func RPCParseError(err error) RPCResponse
func RPCServerError ¶
func RPCServerError(id jsonrpcid, err error) RPCResponse
func (*RPCResponse) String ¶
func (resp *RPCResponse) String() string
func (*RPCResponse) UnmarshalJSON ¶
func (resp *RPCResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON custom JSON unmarshaling due to jsonrpcid being string or int
type ResultABCIInfo ¶
type ResultABCIInfo struct {
Response abci.ResponseInfo `json:"response"`
}
ResultABCIInfo is a info abci msg
type ResultABCIQuery ¶
type ResultABCIQuery struct {
Response abci.ResponseQuery `json:"response"`
}
ResultABCIQuery is response of querying abci msg
type ResultBlock ¶
type ResultBlockResults ¶
type ResultBlockResults struct { Height int64 `json:"height"` TxsResults []*abci.ResponseDeliverTx `json:"txs_results"` TotalGasUsed int64 `json:"total_gas_used"` BeginBlockEvents []abci.Event `json:"begin_block_events"` EndBlockEvents []abci.Event `json:"end_block_events"` ValidatorUpdates []abci.ValidatorUpdate `json:"validator_updates"` ConsensusParamUpdates *tmproto.ConsensusParams `json:"consensus_param_updates"` }
ResultBlockResults return ABCI results from a block
type ResultBlockSearch ¶
type ResultBlockSearch struct { Blocks []*ResultBlock `json:"blocks"` TotalCount int `json:"total_count"` }
ResultBlockSearch defines the RPC response type for a block search by events.
type ResultBlockchainInfo ¶
type ResultBlockchainInfo struct { LastHeight int64 `json:"last_height"` BlockMetas []*tmtype.BlockMeta `json:"block_metas"` }
ResultBlockchainInfo return List of block metadata
type ResultBroadcastEvidence ¶
type ResultBroadcastEvidence struct {
Hash []byte `json:"hash"`
}
ResultBroadcastEvidence is the result of broadcasting evidence
type ResultBroadcastTx ¶
type ResultBroadcastTx struct { Code uint32 `json:"code"` Data bytes.HexBytes `json:"data"` Log string `json:"log"` Codespace string `json:"codespace"` MempoolError string `json:"mempool_error"` Hash bytes.HexBytes `json:"hash"` }
ResultBroadcastTx is the CheckTx result
type ResultBroadcastTxCommit ¶
type ResultBroadcastTxCommit struct { CheckTx abci.ResponseCheckTx `json:"check_tx"` DeliverTx abci.ResponseDeliverTx `json:"deliver_tx"` Hash bytes.HexBytes `json:"hash"` Height int64 `json:"height"` }
ResultBroadcastTxCommit is CheckTx and DeliverTx results
type ResultCheckTx ¶
type ResultCheckTx struct {
abci.ResponseCheckTx
}
ResultCheckTx wraps abci.ResponseCheckTx.
type ResultCommit ¶
type ResultCommit struct { tmtype.SignedHeader `json:"signed_header"` CanonicalCommit bool `json:"canonical"` }
ResultCommit is Commit and Header
type ResultDialPeers ¶
type ResultDialPeers struct {
Log string `json:"log"`
}
ResultDialPeers is Log from dialing peers
type ResultDialSeeds ¶
type ResultDialSeeds struct {
Log string `json:"log"`
}
ResultDialSeeds is log from dialing seeds
type ResultEvent ¶
type ResultEvent struct { Query string `json:"query"` Data tmtype.TMEventData `json:"data"` Events TmEvents `json:"events"` }
ResultEvent is the event data from a subscription
type ResultHeader ¶
ResultHeader represents the response for a Header RPC Client query
type ResultHealth ¶
type ResultHealth struct{}
type ResultNetInfo ¶
type ResultNetInfo struct { Listening bool `json:"listening"` Listeners []string `json:"listeners"` NPeers int `json:"n_peers"` Peers []Peer `json:"peers"` }
ResultNetInfo is a info about peer connections
type ResultStatus ¶
type ResultStatus struct { NodeInfo NodeInfo `json:"node_info"` SyncInfo SyncInfo `json:"sync_info"` ValidatorInfo ValidatorInfo `json:"validator_info"` }
ResultStatus is Node Status
func (*ResultStatus) TxIndexEnabled ¶
func (s *ResultStatus) TxIndexEnabled() bool
type ResultSubscribe ¶
type ResultSubscribe struct{}
type ResultTx ¶
type ResultTx struct { Hash bytes.HexBytes `json:"hash"` Height int64 `json:"height"` Index uint32 `json:"index"` TxResult abci.ResponseDeliverTx `json:"tx_result"` Tx tmtype.Tx `json:"tx"` Proof tmtype.TxProof `json:"proof,omitempty"` }
ResultTx is a result of querying for a tx
type ResultTxSearch ¶
ResultTxSearch is result of searching for txs
type ResultUnconfirmedTxs ¶
type ResultUnconfirmedTxs struct { Count int `json:"n_txs"` Total int `json:"total"` TotalBytes int64 `json:"total_bytes"` Txs []tmtype.Tx `json:"txs"` }
ResultUnconfirmedTxs is list of mempool txs
type ResultUnsafeFlushMempool ¶
type ResultUnsafeFlushMempool struct{}
type ResultUnsafeProfile ¶
type ResultUnsafeProfile struct{}
type ResultUnsubscribe ¶
type ResultUnsubscribe struct{}
type ResultValidators ¶
type ResultValidators struct { BlockHeight int64 `json:"block_height"` Validators []*tmtype.Validator `json:"validators"` // Count of actual validators in this result Count int `json:"count"` // Total number of validators Total int `json:"total"` }
ResultValidators is validators for a height.
type RunState ¶
func NewRunState ¶
NewRunState returns a new unstarted run state tracker with the given logging label and log sink. If logger == nil, a no-op logger is provided by default.
func (*RunState) Quit ¶
func (r *RunState) Quit() <-chan struct{}
Quit returns a channel that is closed when a call to Stop succeeds.
type SyncInfo ¶
type SyncInfo struct { LatestBlockHash bytes.HexBytes `json:"latest_block_hash"` LatestAppHash bytes.HexBytes `json:"latest_app_hash"` LatestBlockHeight int64 `json:"latest_block_height"` LatestBlockTime time.Time `json:"latest_block_time"` EarliestBlockHash bytes.HexBytes `json:"earliest_block_hash"` EarliestAppHash bytes.HexBytes `json:"earliest_app_hash"` EarliestBlockHeight int64 `json:"earliest_block_height"` EarliestBlockTime time.Time `json:"earliest_block_time"` MaxPeerBlockHeight int64 `json:"max_peer_block_height"` CatchingUp bool `json:"catching_up"` TotalSyncedTime time.Duration `json:"total_synced_time"` RemainingTime time.Duration `json:"remaining_time"` TotalSnapshots int64 `json:"total_snapshots"` ChunkProcessAvgTime time.Duration `json:"chunk_process_avg_time"` SnapshotHeight int64 `json:"snapshot_height"` SnapshotChunksCount int64 `json:"snapshot_chunks_count"` SnapshotChunksTotal int64 `json:"snapshot_chunks_total"` BackFilledBlocks int64 `json:"backfilled_blocks"` BackFillBlocksTotal int64 `json:"backfill_blocks_total"` }
SyncInfo is a info about the node's syncing state
type ValidatorInfo ¶
type ValidatorInfo struct { Address bytes.HexBytes `json:"address"` PubKey crypto.PubKey `json:"pub_key"` VotingPower int64 `json:"voting_power"` }
ValidatorInfo is a info about the node's validator
type WSClient ¶
type WSClient struct { *RunState Address string // IP:PORT or /path/to/socket Endpoint string // /websocket/url/endpoint Dialer func(string, string) (net.Conn, error) ResponsesCh chan RPCResponse PingPongLatencyTimer metrics.Timer // contains filtered or unexported fields }
func NewWSWithOptions ¶
func (*WSClient) CallWithArrayParams ¶
func (*WSClient) IsReconnecting ¶
func (*WSClient) OnReconnect ¶
func (c *WSClient) OnReconnect(cb func())
func (*WSClient) Subscribe ¶
Subscribe to a query. Note the server must have a "subscribe" route defined.
func (*WSClient) Unsubscribe ¶
Unsubscribe from a query. Note the server must have a "unsubscribe" route defined.
type WSOptions ¶
type WSOptions struct { MaxReconnectAttempts uint // maximum attempts to reconnect ReadWait time.Duration // deadline for any read op WriteWait time.Duration // deadline for any write op PingPeriod time.Duration // frequency with which pings are sent }
func DefaultWSOptions ¶
func DefaultWSOptions() WSOptions
type WSRPCConnection ¶
type WSRPCConnection interface { // GetRemoteAddr returns a remote address of the connection. GetRemoteAddr() string // WriteRPCResponse writes the response onto connection (BLOCKING). WriteRPCResponse(context.Context, RPCResponse) error // TryWriteRPCResponse tries to write the response onto connection (NON-BLOCKING). TryWriteRPCResponse(RPCResponse) bool // Context returns the connection's context. Context() context.Context }
WSRPCConnection represents a websocket connection.