Documentation ¶
Overview ¶
Package core defines the Tendermint RPC endpoints.
Tendermint ships with its own JSONRPC library - https://github.com/ari-anchor/sei-tendermint/tree/master/rpc/jsonrpc.
## Get the list
An HTTP Get request to the root RPC endpoint shows a list of available endpoints.
```bash curl 'localhost:26657' ```
> Response:
```plain Available endpoints: /abci_info /dump_consensus_state /genesis /net_info /num_unconfirmed_txs /status /health /unconfirmed_txs /unsafe_flush_mempool /validators
Endpoints that require arguments: /abci_query?path=_&data=_&prove=_ /block?height=_ /blockchain?minHeight=_&maxHeight=_ /broadcast_tx_async?tx=_ /broadcast_tx_commit?tx=_ /broadcast_tx_sync?tx=_ /commit?height=_ /dial_seeds?seeds=_ /dial_persistent_peers?persistent_peers=_ /subscribe?event=_ /tx?hash=_&prove=_ /unsubscribe?event=_ ```
Index ¶
- Constants
- type Environment
- func (env *Environment) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error)
- func (env *Environment) ABCIQuery(ctx context.Context, req *coretypes.RequestABCIQuery) (*coretypes.ResultABCIQuery, error)
- func (env *Environment) Block(ctx context.Context, req *coretypes.RequestBlockInfo) (*coretypes.ResultBlock, error)
- func (env *Environment) BlockByHash(ctx context.Context, req *coretypes.RequestBlockByHash) (*coretypes.ResultBlock, error)
- func (env *Environment) BlockResults(ctx context.Context, req *coretypes.RequestBlockInfo) (*coretypes.ResultBlockResults, error)
- func (env *Environment) BlockSearch(ctx context.Context, req *coretypes.RequestBlockSearch) (*coretypes.ResultBlockSearch, error)
- func (env *Environment) BlockchainInfo(ctx context.Context, req *coretypes.RequestBlockchainInfo) (*coretypes.ResultBlockchainInfo, error)
- func (env *Environment) BroadcastEvidence(ctx context.Context, req *coretypes.RequestBroadcastEvidence) (*coretypes.ResultBroadcastEvidence, error)
- func (env *Environment) BroadcastTx(ctx context.Context, req *coretypes.RequestBroadcastTx) (*coretypes.ResultBroadcastTx, error)
- func (env *Environment) BroadcastTxAsync(ctx context.Context, req *coretypes.RequestBroadcastTx) (*coretypes.ResultBroadcastTx, error)
- func (env *Environment) BroadcastTxCommit(ctx context.Context, req *coretypes.RequestBroadcastTx) (*coretypes.ResultBroadcastTxCommit, error)
- func (env *Environment) BroadcastTxSync(ctx context.Context, req *coretypes.RequestBroadcastTx) (*coretypes.ResultBroadcastTx, error)
- func (env *Environment) CheckTx(ctx context.Context, req *coretypes.RequestCheckTx) (*coretypes.ResultCheckTx, error)
- func (env *Environment) Commit(ctx context.Context, req *coretypes.RequestBlockInfo) (*coretypes.ResultCommit, error)
- func (env *Environment) ConsensusParams(ctx context.Context, req *coretypes.RequestConsensusParams) (*coretypes.ResultConsensusParams, error)
- func (env *Environment) DumpConsensusState(ctx context.Context) (*coretypes.ResultDumpConsensusState, error)
- func (env *Environment) Events(ctx context.Context, req *coretypes.RequestEvents) (*coretypes.ResultEvents, error)
- func (env *Environment) Genesis(ctx context.Context) (*coretypes.ResultGenesis, error)
- func (env *Environment) GenesisChunked(ctx context.Context, req *coretypes.RequestGenesisChunked) (*coretypes.ResultGenesisChunk, error)
- func (env *Environment) GetConsensusState(ctx context.Context) (*coretypes.ResultConsensusState, error)
- func (env *Environment) Header(ctx context.Context, req *coretypes.RequestBlockInfo) (*coretypes.ResultHeader, error)
- func (env *Environment) HeaderByHash(ctx context.Context, req *coretypes.RequestBlockByHash) (*coretypes.ResultHeader, error)
- func (env *Environment) Health(ctx context.Context) (*coretypes.ResultHealth, error)
- func (env *Environment) InitGenesisChunks() error
- func (env *Environment) NetInfo(ctx context.Context) (*coretypes.ResultNetInfo, error)
- func (env *Environment) NumUnconfirmedTxs(ctx context.Context) (*coretypes.ResultUnconfirmedTxs, error)
- func (env *Environment) RemoveTx(ctx context.Context, req *coretypes.RequestRemoveTx) error
- func (env *Environment) StartService(ctx context.Context, conf *config.Config) ([]net.Listener, error)
- func (env *Environment) Status(ctx context.Context) (*coretypes.ResultStatus, error)
- func (env *Environment) Subscribe(ctx context.Context, req *coretypes.RequestSubscribe) (*coretypes.ResultSubscribe, error)
- func (env *Environment) Tx(ctx context.Context, req *coretypes.RequestTx) (*coretypes.ResultTx, error)
- func (env *Environment) TxSearch(ctx context.Context, req *coretypes.RequestTxSearch) (*coretypes.ResultTxSearch, error)
- func (env *Environment) UnconfirmedTxs(ctx context.Context, req *coretypes.RequestUnconfirmedTxs) (*coretypes.ResultUnconfirmedTxs, error)
- func (env *Environment) UnsafeFlushMempool(ctx context.Context) (*coretypes.ResultUnsafeFlushMempool, error)
- func (env *Environment) Unsubscribe(ctx context.Context, req *coretypes.RequestUnsubscribe) (*coretypes.ResultUnsubscribe, error)
- func (env *Environment) UnsubscribeAll(ctx context.Context) (*coretypes.ResultUnsubscribe, error)
- func (env *Environment) Validators(ctx context.Context, req *coretypes.RequestValidators) (*coretypes.ResultValidators, error)
- type RPCService
- type RPCUnsafe
- type RouteOptions
- type RoutesMap
Constants ¶
const ( // SubscribeTimeout is the maximum time we wait to subscribe for an event. // must be less than the server's write timeout (see rpcserver.DefaultConfig) SubscribeTimeout = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Environment ¶
type Environment struct { // external, thread safe interfaces ProxyApp abciclient.Client // interfaces defined in types and above StateStore sm.Store BlockStore sm.BlockStore EvidencePool sm.EvidencePool ConsensusState consensusState ConsensusReactor *consensus.Reactor BlockSyncReactor *blocksync.Reactor IsListening bool Listeners []string NodeInfo types.NodeInfo // interfaces for new p2p interfaces PeerManager peerManager // objects PubKey crypto.PubKey GenDoc *types.GenesisDoc // cache the genesis structure EventSinks []indexer.EventSink EventBus *eventbus.EventBus // thread safe EventLog *eventlog.Log Mempool mempool.Mempool StateSyncMetricer statesync.Metricer Logger log.Logger Config config.RPCConfig // contains filtered or unexported fields }
---------------------------------------------- Environment contains objects and interfaces used by the RPC. It is expected to be setup once during startup.
func (*Environment) ABCIInfo ¶
func (env *Environment) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error)
ABCIInfo gets some info about the application. More: https://docs.tendermint.com/master/rpc/#/ABCI/abci_info
func (*Environment) ABCIQuery ¶
func (env *Environment) ABCIQuery(ctx context.Context, req *coretypes.RequestABCIQuery) (*coretypes.ResultABCIQuery, error)
ABCIQuery queries the application for some information. More: https://docs.tendermint.com/master/rpc/#/ABCI/abci_query
func (*Environment) Block ¶
func (env *Environment) Block(ctx context.Context, req *coretypes.RequestBlockInfo) (*coretypes.ResultBlock, error)
Block gets block at a given height. If no height is provided, it will fetch the latest block. More: https://docs.tendermint.com/master/rpc/#/Info/block
func (*Environment) BlockByHash ¶
func (env *Environment) BlockByHash(ctx context.Context, req *coretypes.RequestBlockByHash) (*coretypes.ResultBlock, error)
BlockByHash gets block by hash. More: https://docs.tendermint.com/master/rpc/#/Info/block_by_hash
func (*Environment) BlockResults ¶
func (env *Environment) BlockResults(ctx context.Context, req *coretypes.RequestBlockInfo) (*coretypes.ResultBlockResults, error)
BlockResults gets ABCIResults at a given height. If no height is provided, it will fetch results for the latest block.
Results are for the height of the block containing the txs. More: https://docs.tendermint.com/master/rpc/#/Info/block_results
func (*Environment) BlockSearch ¶
func (env *Environment) BlockSearch(ctx context.Context, req *coretypes.RequestBlockSearch) (*coretypes.ResultBlockSearch, error)
BlockSearch searches for a paginated set of blocks matching the provided query.
func (*Environment) BlockchainInfo ¶
func (env *Environment) BlockchainInfo(ctx context.Context, req *coretypes.RequestBlockchainInfo) (*coretypes.ResultBlockchainInfo, error)
BlockchainInfo gets block headers for minHeight <= height <= maxHeight.
If maxHeight does not yet exist, blocks up to the current height will be returned. If minHeight does not exist (due to pruning), earliest existing height will be used.
At most 20 items will be returned. Block headers are returned in descending order (highest first).
More: https://docs.tendermint.com/master/rpc/#/Info/blockchain
func (*Environment) BroadcastEvidence ¶
func (env *Environment) BroadcastEvidence(ctx context.Context, req *coretypes.RequestBroadcastEvidence) (*coretypes.ResultBroadcastEvidence, error)
BroadcastEvidence broadcasts evidence of the misbehavior. More: https://docs.tendermint.com/master/rpc/#/Evidence/broadcast_evidence
func (*Environment) BroadcastTx ¶
func (env *Environment) BroadcastTx(ctx context.Context, req *coretypes.RequestBroadcastTx) (*coretypes.ResultBroadcastTx, error)
BroadcastTx returns with the response from CheckTx. Does not wait for DeliverTx result. More: https://docs.tendermint.com/master/rpc/#/Tx/broadcast_tx_sync
func (*Environment) BroadcastTxAsync ¶
func (env *Environment) BroadcastTxAsync(ctx context.Context, req *coretypes.RequestBroadcastTx) (*coretypes.ResultBroadcastTx, error)
BroadcastTxAsync returns right away, with no response. Does not wait for CheckTx nor DeliverTx results. More: https://docs.tendermint.com/master/rpc/#/Tx/broadcast_tx_async Deprecated and should be removed in 0.37
func (*Environment) BroadcastTxCommit ¶
func (env *Environment) BroadcastTxCommit(ctx context.Context, req *coretypes.RequestBroadcastTx) (*coretypes.ResultBroadcastTxCommit, error)
BroadcastTxCommit returns with the responses from CheckTx and DeliverTx. More: https://docs.tendermint.com/master/rpc/#/Tx/broadcast_tx_commit
func (*Environment) BroadcastTxSync ¶
func (env *Environment) BroadcastTxSync(ctx context.Context, req *coretypes.RequestBroadcastTx) (*coretypes.ResultBroadcastTx, error)
Deprecated and should be remove in 0.37
func (*Environment) CheckTx ¶
func (env *Environment) CheckTx(ctx context.Context, req *coretypes.RequestCheckTx) (*coretypes.ResultCheckTx, error)
CheckTx checks the transaction without executing it. The transaction won't be added to the mempool either. More: https://docs.tendermint.com/master/rpc/#/Tx/check_tx
func (*Environment) Commit ¶
func (env *Environment) Commit(ctx context.Context, req *coretypes.RequestBlockInfo) (*coretypes.ResultCommit, error)
Commit gets block commit at a given height. If no height is provided, it will fetch the commit for the latest block. More: https://docs.tendermint.com/master/rpc/#/Info/commit
func (*Environment) ConsensusParams ¶
func (env *Environment) ConsensusParams(ctx context.Context, req *coretypes.RequestConsensusParams) (*coretypes.ResultConsensusParams, error)
ConsensusParams gets the consensus parameters at the given block height. If no height is provided, it will fetch the latest consensus params. More: https://docs.tendermint.com/master/rpc/#/Info/consensus_params
func (*Environment) DumpConsensusState ¶
func (env *Environment) DumpConsensusState(ctx context.Context) (*coretypes.ResultDumpConsensusState, error)
DumpConsensusState dumps consensus state. UNSTABLE More: https://docs.tendermint.com/master/rpc/#/Info/dump_consensus_state
func (*Environment) Events ¶
func (env *Environment) Events(ctx context.Context, req *coretypes.RequestEvents) (*coretypes.ResultEvents, error)
Events applies a query to the event log. If an event log is not enabled, Events reports an error. Otherwise, it filters the current contents of the log to return matching events.
Events returns up to maxItems of the newest eligible event items. An item is eligible if it is older than before (or before is zero), it is newer than after (or after is zero), and its data matches the filter. A nil filter matches all event data.
If before is zero and no eligible event items are available, Events waits for up to waitTime for a matching item to become available. The wait is terminated early if ctx ends.
If maxItems ≤ 0, a default positive number of events is chosen. The values of maxItems and waitTime may be capped to sensible internal maxima without reporting an error to the caller.
func (*Environment) Genesis ¶
func (env *Environment) Genesis(ctx context.Context) (*coretypes.ResultGenesis, error)
Genesis returns genesis file. More: https://docs.tendermint.com/master/rpc/#/Info/genesis
func (*Environment) GenesisChunked ¶
func (env *Environment) GenesisChunked(ctx context.Context, req *coretypes.RequestGenesisChunked) (*coretypes.ResultGenesisChunk, error)
func (*Environment) GetConsensusState ¶
func (env *Environment) GetConsensusState(ctx context.Context) (*coretypes.ResultConsensusState, error)
ConsensusState returns a concise summary of the consensus state. UNSTABLE More: https://docs.tendermint.com/master/rpc/#/Info/consensus_state
func (*Environment) Header ¶
func (env *Environment) Header(ctx context.Context, req *coretypes.RequestBlockInfo) (*coretypes.ResultHeader, error)
Header gets block header at a given height. If no height is provided, it will fetch the latest header. More: https://docs.tendermint.com/master/rpc/#/Info/header
func (*Environment) HeaderByHash ¶
func (env *Environment) HeaderByHash(ctx context.Context, req *coretypes.RequestBlockByHash) (*coretypes.ResultHeader, error)
HeaderByHash gets header by hash. More: https://docs.tendermint.com/master/rpc/#/Info/header_by_hash
func (*Environment) Health ¶
func (env *Environment) Health(ctx context.Context) (*coretypes.ResultHealth, error)
Health gets node health. Returns empty result (200 OK) on success, no response - in case of an error. More: https://docs.tendermint.com/master/rpc/#/Info/health
func (*Environment) InitGenesisChunks ¶
func (env *Environment) InitGenesisChunks() error
InitGenesisChunks configures the environment and should be called on service startup.
func (*Environment) NetInfo ¶
func (env *Environment) NetInfo(ctx context.Context) (*coretypes.ResultNetInfo, error)
NetInfo returns network info. More: https://docs.tendermint.com/master/rpc/#/Info/net_info
func (*Environment) NumUnconfirmedTxs ¶
func (env *Environment) NumUnconfirmedTxs(ctx context.Context) (*coretypes.ResultUnconfirmedTxs, error)
NumUnconfirmedTxs gets number of unconfirmed transactions. More: https://docs.tendermint.com/master/rpc/#/Info/num_unconfirmed_txs
func (*Environment) RemoveTx ¶
func (env *Environment) RemoveTx(ctx context.Context, req *coretypes.RequestRemoveTx) error
func (*Environment) StartService ¶
func (env *Environment) StartService(ctx context.Context, conf *config.Config) ([]net.Listener, error)
StartService constructs and starts listeners for the RPC service according to the config object, returning an error if the service cannot be constructed or started. The listeners, which provide access to the service, run until the context is canceled.
func (*Environment) Status ¶
func (env *Environment) Status(ctx context.Context) (*coretypes.ResultStatus, error)
Status returns Tendermint status including node info, pubkey, latest block hash, app hash, block height, current max peer block height, and time. More: https://docs.tendermint.com/master/rpc/#/Info/status
func (*Environment) Subscribe ¶
func (env *Environment) Subscribe(ctx context.Context, req *coretypes.RequestSubscribe) (*coretypes.ResultSubscribe, error)
Subscribe for events via WebSocket. More: https://docs.tendermint.com/master/rpc/#/Websocket/subscribe
func (*Environment) Tx ¶
func (env *Environment) Tx(ctx context.Context, req *coretypes.RequestTx) (*coretypes.ResultTx, error)
Tx allows you to query the transaction results. `nil` could mean the transaction is in the mempool, invalidated, or was not sent in the first place. More: https://docs.tendermint.com/master/rpc/#/Info/tx
func (*Environment) TxSearch ¶
func (env *Environment) TxSearch(ctx context.Context, req *coretypes.RequestTxSearch) (*coretypes.ResultTxSearch, error)
TxSearch allows you to query for multiple transactions results. It returns a list of transactions (maximum ?per_page entries) and the total count. More: https://docs.tendermint.com/master/rpc/#/Info/tx_search
func (*Environment) UnconfirmedTxs ¶
func (env *Environment) UnconfirmedTxs(ctx context.Context, req *coretypes.RequestUnconfirmedTxs) (*coretypes.ResultUnconfirmedTxs, error)
UnconfirmedTxs gets unconfirmed transactions from the mempool in order of priority More: https://docs.tendermint.com/master/rpc/#/Info/unconfirmed_txs
func (*Environment) UnsafeFlushMempool ¶
func (env *Environment) UnsafeFlushMempool(ctx context.Context) (*coretypes.ResultUnsafeFlushMempool, error)
UnsafeFlushMempool removes all transactions from the mempool.
func (*Environment) Unsubscribe ¶
func (env *Environment) Unsubscribe(ctx context.Context, req *coretypes.RequestUnsubscribe) (*coretypes.ResultUnsubscribe, error)
Unsubscribe from events via WebSocket. More: https://docs.tendermint.com/master/rpc/#/Websocket/unsubscribe
func (*Environment) UnsubscribeAll ¶
func (env *Environment) UnsubscribeAll(ctx context.Context) (*coretypes.ResultUnsubscribe, error)
UnsubscribeAll from all events via WebSocket. More: https://docs.tendermint.com/master/rpc/#/Websocket/unsubscribe_all
func (*Environment) Validators ¶
func (env *Environment) Validators(ctx context.Context, req *coretypes.RequestValidators) (*coretypes.ResultValidators, error)
Validators gets the validator set at the given block height.
If no height is provided, it will fetch the latest validator set. Note the validators are sorted by their voting power - this is the canonical order for the validators in the set as used in computing their Merkle root.
More: https://docs.tendermint.com/master/rpc/#/Info/validators
type RPCService ¶
type RPCService interface { ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error) ABCIQuery(ctx context.Context, req *coretypes.RequestABCIQuery) (*coretypes.ResultABCIQuery, error) Block(ctx context.Context, req *coretypes.RequestBlockInfo) (*coretypes.ResultBlock, error) BlockByHash(ctx context.Context, req *coretypes.RequestBlockByHash) (*coretypes.ResultBlock, error) BlockResults(ctx context.Context, req *coretypes.RequestBlockInfo) (*coretypes.ResultBlockResults, error) BlockSearch(ctx context.Context, req *coretypes.RequestBlockSearch) (*coretypes.ResultBlockSearch, error) BlockchainInfo(ctx context.Context, req *coretypes.RequestBlockchainInfo) (*coretypes.ResultBlockchainInfo, error) BroadcastEvidence(ctx context.Context, req *coretypes.RequestBroadcastEvidence) (*coretypes.ResultBroadcastEvidence, error) BroadcastTx(ctx context.Context, req *coretypes.RequestBroadcastTx) (*coretypes.ResultBroadcastTx, error) BroadcastTxAsync(ctx context.Context, req *coretypes.RequestBroadcastTx) (*coretypes.ResultBroadcastTx, error) BroadcastTxCommit(ctx context.Context, req *coretypes.RequestBroadcastTx) (*coretypes.ResultBroadcastTxCommit, error) BroadcastTxSync(ctx context.Context, req *coretypes.RequestBroadcastTx) (*coretypes.ResultBroadcastTx, error) CheckTx(ctx context.Context, req *coretypes.RequestCheckTx) (*coretypes.ResultCheckTx, error) Commit(ctx context.Context, req *coretypes.RequestBlockInfo) (*coretypes.ResultCommit, error) ConsensusParams(ctx context.Context, req *coretypes.RequestConsensusParams) (*coretypes.ResultConsensusParams, error) DumpConsensusState(ctx context.Context) (*coretypes.ResultDumpConsensusState, error) Events(ctx context.Context, req *coretypes.RequestEvents) (*coretypes.ResultEvents, error) Genesis(ctx context.Context) (*coretypes.ResultGenesis, error) GenesisChunked(ctx context.Context, req *coretypes.RequestGenesisChunked) (*coretypes.ResultGenesisChunk, error) GetConsensusState(ctx context.Context) (*coretypes.ResultConsensusState, error) Header(ctx context.Context, req *coretypes.RequestBlockInfo) (*coretypes.ResultHeader, error) HeaderByHash(ctx context.Context, req *coretypes.RequestBlockByHash) (*coretypes.ResultHeader, error) Health(ctx context.Context) (*coretypes.ResultHealth, error) NetInfo(ctx context.Context) (*coretypes.ResultNetInfo, error) NumUnconfirmedTxs(ctx context.Context) (*coretypes.ResultUnconfirmedTxs, error) RemoveTx(ctx context.Context, req *coretypes.RequestRemoveTx) error Status(ctx context.Context) (*coretypes.ResultStatus, error) Subscribe(ctx context.Context, req *coretypes.RequestSubscribe) (*coretypes.ResultSubscribe, error) Tx(ctx context.Context, req *coretypes.RequestTx) (*coretypes.ResultTx, error) TxSearch(ctx context.Context, req *coretypes.RequestTxSearch) (*coretypes.ResultTxSearch, error) UnconfirmedTxs(ctx context.Context, req *coretypes.RequestUnconfirmedTxs) (*coretypes.ResultUnconfirmedTxs, error) Unsubscribe(ctx context.Context, req *coretypes.RequestUnsubscribe) (*coretypes.ResultUnsubscribe, error) UnsubscribeAll(ctx context.Context) (*coretypes.ResultUnsubscribe, error) Validators(ctx context.Context, req *coretypes.RequestValidators) (*coretypes.ResultValidators, error) }
RPCService defines the set of methods exported by the RPC service implementation, for use in constructing a routing table.
type RPCUnsafe ¶
type RPCUnsafe interface {
UnsafeFlushMempool(ctx context.Context) (*coretypes.ResultUnsafeFlushMempool, error)
}
RPCUnsafe defines the set of "unsafe" methods that may optionally be exported by the RPC service.
type RouteOptions ¶
type RouteOptions struct {
Unsafe bool // include "unsafe" methods (default false)
}
RouteOptions provide optional settings to NewRoutesMap. A nil *RouteOptions is ready for use and provides defaults as specified.
type RoutesMap ¶
func NewRoutesMap ¶
func NewRoutesMap(svc RPCService, opts *RouteOptions) RoutesMap
NewRoutesMap constructs an RPC routing map for the given service implementation. If svc implements RPCUnsafe and opts.Unsafe is true, the "unsafe" methods will also be added to the map. The caller may also edit the map after construction; each call to NewRoutesMap returns a fresh map.