Documentation ¶
Overview ¶
Package core defines the CometBFT RPC endpoints.
CometBFT ships with its own JSONRPC library - https://github.com/cometbft/cometbft/tree/v0.38.x/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 Consensus
- type Environment
- func (env *Environment) ABCIInfo(_ *rpctypes.Context) (*ctypes.ResultABCIInfo, error)
- func (env *Environment) ABCIQuery(_ *rpctypes.Context, path string, data bytes.HexBytes, height int64, ...) (*ctypes.ResultABCIQuery, error)
- func (env *Environment) AddUnsafeRoutes(routes RoutesMap)
- func (env *Environment) Block(_ *rpctypes.Context, heightPtr *int64) (*ctypes.ResultBlock, error)
- func (env *Environment) BlockByHash(_ *rpctypes.Context, hash []byte) (*ctypes.ResultBlock, error)
- func (env *Environment) BlockResults(_ *rpctypes.Context, heightPtr *int64) (*ctypes.ResultBlockResults, error)
- func (env *Environment) BlockSearch(ctx *rpctypes.Context, query string, pagePtr, perPagePtr *int, orderBy string) (*ctypes.ResultBlockSearch, error)
- func (env *Environment) BlockchainInfo(_ *rpctypes.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)
- func (env *Environment) BroadcastEvidence(_ *rpctypes.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error)
- func (env *Environment) BroadcastTxAsync(_ *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- func (env *Environment) BroadcastTxCommit(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
- func (env *Environment) BroadcastTxSync(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)
- func (env *Environment) CheckTx(_ *rpctypes.Context, tx types.Tx) (*ctypes.ResultCheckTx, error)
- func (env *Environment) Commit(_ *rpctypes.Context, heightPtr *int64) (*ctypes.ResultCommit, error)
- func (env *Environment) ConsensusParams(_ *rpctypes.Context, heightPtr *int64) (*ctypes.ResultConsensusParams, error)
- func (env *Environment) DumpConsensusState(*rpctypes.Context) (*ctypes.ResultDumpConsensusState, error)
- func (env *Environment) Genesis(*rpctypes.Context) (*ctypes.ResultGenesis, error)
- func (env *Environment) GenesisChunked(_ *rpctypes.Context, chunk uint) (*ctypes.ResultGenesisChunk, error)
- func (env *Environment) GetConsensusState(*rpctypes.Context) (*ctypes.ResultConsensusState, error)
- func (env *Environment) GetRoutes() RoutesMap
- func (env *Environment) Header(_ *rpctypes.Context, heightPtr *int64) (*ctypes.ResultHeader, error)
- func (env *Environment) HeaderByHash(_ *rpctypes.Context, hash bytes.HexBytes) (*ctypes.ResultHeader, error)
- func (env *Environment) Health(*rpctypes.Context) (*ctypes.ResultHealth, error)
- func (env *Environment) InitGenesisChunks() error
- func (env *Environment) NetInfo(*rpctypes.Context) (*ctypes.ResultNetInfo, error)
- func (env *Environment) NumUnconfirmedTxs(*rpctypes.Context) (*ctypes.ResultUnconfirmedTxs, error)
- func (env *Environment) Status(*rpctypes.Context) (*ctypes.ResultStatus, error)
- func (env *Environment) Subscribe(ctx *rpctypes.Context, query string) (*ctypes.ResultSubscribe, error)
- func (env *Environment) Tx(_ *rpctypes.Context, hash []byte, prove bool) (*ctypes.ResultTx, error)
- func (env *Environment) TxSearch(ctx *rpctypes.Context, query string, prove bool, pagePtr, perPagePtr *int, ...) (*ctypes.ResultTxSearch, error)
- func (env *Environment) UnconfirmedTxs(_ *rpctypes.Context, limitPtr *int) (*ctypes.ResultUnconfirmedTxs, error)
- func (env *Environment) UnsafeDialPeers(_ *rpctypes.Context, peers []string, persistent, unconditional, private bool) (*ctypes.ResultDialPeers, error)
- func (env *Environment) UnsafeDialSeeds(_ *rpctypes.Context, seeds []string) (*ctypes.ResultDialSeeds, error)
- func (env *Environment) UnsafeFlushMempool(*rpctypes.Context) (*ctypes.ResultUnsafeFlushMempool, error)
- func (env *Environment) Unsubscribe(ctx *rpctypes.Context, query string) (*ctypes.ResultUnsubscribe, error)
- func (env *Environment) UnsubscribeAll(ctx *rpctypes.Context) (*ctypes.ResultUnsubscribe, error)
- func (env *Environment) Validators(_ *rpctypes.Context, heightPtr *int64, pagePtr, perPagePtr *int) (*ctypes.ResultValidators, error)
- 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 ProxyAppQuery proxy.AppConnQuery ProxyAppMempool proxy.AppConnMempool // interfaces defined in types and above StateStore sm.Store BlockStore sm.BlockStore EvidencePool sm.EvidencePool ConsensusState Consensus ConsensusReactor consensusReactor P2PPeers peers P2PTransport transport // objects PubKey crypto.PubKey GenDoc *types.GenesisDoc // cache the genesis structure TxIndexer txindex.TxIndexer BlockIndexer indexer.BlockIndexer EventBus *types.EventBus // thread safe Mempool mempl.Mempool Logger log.Logger Config cfg.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 ¶ added in v0.38.0
func (env *Environment) ABCIInfo(_ *rpctypes.Context) (*ctypes.ResultABCIInfo, error)
ABCIInfo gets some info about the application. More: https://docs.cometbft.com/v0.38.x/rpc/#/ABCI/abci_info
func (*Environment) ABCIQuery ¶ added in v0.38.0
func (env *Environment) ABCIQuery( _ *rpctypes.Context, path string, data bytes.HexBytes, height int64, prove bool, ) (*ctypes.ResultABCIQuery, error)
ABCIQuery queries the application for some information. More: https://docs.cometbft.com/v0.38.x/rpc/#/ABCI/abci_query
func (*Environment) AddUnsafeRoutes ¶ added in v0.38.0
func (env *Environment) AddUnsafeRoutes(routes RoutesMap)
AddUnsafeRoutes adds unsafe routes.
func (*Environment) Block ¶ added in v0.38.0
func (env *Environment) Block(_ *rpctypes.Context, heightPtr *int64) (*ctypes.ResultBlock, error)
Block gets block at a given height. If no height is provided, it will fetch the latest block. More: https://docs.cometbft.com/v0.38.x/rpc/#/Info/block
func (*Environment) BlockByHash ¶ added in v0.38.0
func (env *Environment) BlockByHash(_ *rpctypes.Context, hash []byte) (*ctypes.ResultBlock, error)
BlockByHash gets block by hash. More: https://docs.cometbft.com/v0.38.x/rpc/#/Info/block_by_hash
func (*Environment) BlockResults ¶ added in v0.38.0
func (env *Environment) BlockResults(_ *rpctypes.Context, heightPtr *int64) (*ctypes.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. Thus response.results.deliver_tx[5] is the results of executing getBlock(h).Txs[5] More: https://docs.cometbft.com/v0.38.x/rpc/#/Info/block_results
func (*Environment) BlockSearch ¶ added in v0.38.0
func (env *Environment) BlockSearch( ctx *rpctypes.Context, query string, pagePtr, perPagePtr *int, orderBy string, ) (*ctypes.ResultBlockSearch, error)
BlockSearch searches for a paginated set of blocks matching FinalizeBlock event search criteria.
func (*Environment) BlockchainInfo ¶ added in v0.38.0
func (env *Environment) BlockchainInfo( _ *rpctypes.Context, minHeight, maxHeight int64, ) (*ctypes.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.cometbft.com/v0.38.x/rpc/#/Info/blockchain
func (*Environment) BroadcastEvidence ¶ added in v0.38.0
func (env *Environment) BroadcastEvidence( _ *rpctypes.Context, ev types.Evidence, ) (*ctypes.ResultBroadcastEvidence, error)
BroadcastEvidence broadcasts evidence of the misbehavior. More: https://docs.cometbft.com/v0.38.x/rpc/#/Evidence/broadcast_evidence
func (*Environment) BroadcastTxAsync ¶ added in v0.38.0
func (env *Environment) BroadcastTxAsync(_ *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)
BroadcastTxAsync returns right away, with no response. Does not wait for CheckTx nor transaction results. More: https://docs.cometbft.com/v0.38.x/rpc/#/Tx/broadcast_tx_async
func (*Environment) BroadcastTxCommit ¶ added in v0.38.0
func (env *Environment) BroadcastTxCommit(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
BroadcastTxCommit returns with the responses from CheckTx and ExecTxResult. More: https://docs.cometbft.com/v0.38.x/rpc/#/Tx/broadcast_tx_commit
func (*Environment) BroadcastTxSync ¶ added in v0.38.0
func (env *Environment) BroadcastTxSync(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)
BroadcastTxSync returns with the response from CheckTx. Does not wait for the transaction result. More: https://docs.cometbft.com/v0.38.x/rpc/#/Tx/broadcast_tx_sync
func (*Environment) CheckTx ¶ added in v0.38.0
func (env *Environment) CheckTx(_ *rpctypes.Context, tx types.Tx) (*ctypes.ResultCheckTx, error)
CheckTx checks the transaction without executing it. The transaction won't be added to the mempool either. More: https://docs.cometbft.com/v0.38.x/rpc/#/Tx/check_tx
func (*Environment) Commit ¶ added in v0.38.0
func (env *Environment) Commit(_ *rpctypes.Context, heightPtr *int64) (*ctypes.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.cometbft.com/v0.38.x/rpc/#/Info/commit
func (*Environment) ConsensusParams ¶ added in v0.38.0
func (env *Environment) ConsensusParams( _ *rpctypes.Context, heightPtr *int64, ) (*ctypes.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.cometbft.com/v0.38.x/rpc/#/Info/consensus_params
func (*Environment) DumpConsensusState ¶ added in v0.38.0
func (env *Environment) DumpConsensusState(*rpctypes.Context) (*ctypes.ResultDumpConsensusState, error)
DumpConsensusState dumps consensus state. UNSTABLE More: https://docs.cometbft.com/v0.38.x/rpc/#/Info/dump_consensus_state
func (*Environment) Genesis ¶ added in v0.38.0
func (env *Environment) Genesis(*rpctypes.Context) (*ctypes.ResultGenesis, error)
Genesis returns genesis file. More: https://docs.cometbft.com/v0.38.x/rpc/#/Info/genesis
func (*Environment) GenesisChunked ¶ added in v0.38.0
func (env *Environment) GenesisChunked(_ *rpctypes.Context, chunk uint) (*ctypes.ResultGenesisChunk, error)
func (*Environment) GetConsensusState ¶ added in v0.38.0
func (env *Environment) GetConsensusState(*rpctypes.Context) (*ctypes.ResultConsensusState, error)
ConsensusState returns a concise summary of the consensus state. UNSTABLE More: https://docs.cometbft.com/v0.38.x/rpc/#/Info/consensus_state
func (*Environment) GetRoutes ¶ added in v0.38.0
func (env *Environment) GetRoutes() RoutesMap
Routes is a map of available routes.
func (*Environment) Header ¶ added in v0.38.0
func (env *Environment) Header(_ *rpctypes.Context, heightPtr *int64) (*ctypes.ResultHeader, error)
Header gets block header at a given height. If no height is provided, it will fetch the latest header. More: https://docs.cometbft.com/v0.38.x/rpc/#/Info/header
func (*Environment) HeaderByHash ¶ added in v0.38.0
func (env *Environment) HeaderByHash(_ *rpctypes.Context, hash bytes.HexBytes) (*ctypes.ResultHeader, error)
HeaderByHash gets header by hash. More: https://docs.cometbft.com/v0.38.x/rpc/#/Info/header_by_hash
func (*Environment) Health ¶ added in v0.38.0
func (env *Environment) Health(*rpctypes.Context) (*ctypes.ResultHealth, error)
Health gets node health. Returns empty result (200 OK) on success, no response - in case of an error. More: https://docs.cometbft.com/v0.38.x/rpc/#/Info/health
func (*Environment) InitGenesisChunks ¶ added in v0.38.0
func (env *Environment) InitGenesisChunks() error
InitGenesisChunks configures the environment and should be called on service startup.
func (*Environment) NetInfo ¶ added in v0.38.0
func (env *Environment) NetInfo(*rpctypes.Context) (*ctypes.ResultNetInfo, error)
NetInfo returns network info. More: https://docs.cometbft.com/v0.38.x/rpc/#/Info/net_info
func (*Environment) NumUnconfirmedTxs ¶ added in v0.38.0
func (env *Environment) NumUnconfirmedTxs(*rpctypes.Context) (*ctypes.ResultUnconfirmedTxs, error)
NumUnconfirmedTxs gets number of unconfirmed transactions. More: https://docs.cometbft.com/v0.38.x/rpc/#/Info/num_unconfirmed_txs
func (*Environment) Status ¶ added in v0.38.0
func (env *Environment) Status(*rpctypes.Context) (*ctypes.ResultStatus, error)
Status returns CometBFT status including node info, pubkey, latest block hash, app hash, block height and time. More: https://docs.cometbft.com/v0.38.x/rpc/#/Info/status
func (*Environment) Subscribe ¶ added in v0.38.0
func (env *Environment) Subscribe(ctx *rpctypes.Context, query string) (*ctypes.ResultSubscribe, error)
Subscribe for events via WebSocket. More: https://docs.cometbft.com/v0.38.x/rpc/#/Websocket/subscribe
func (*Environment) Tx ¶ added in v0.38.0
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.cometbft.com/v0.38.x/rpc/#/Info/tx
func (*Environment) TxSearch ¶ added in v0.38.0
func (env *Environment) TxSearch( ctx *rpctypes.Context, query string, prove bool, pagePtr, perPagePtr *int, orderBy string, ) (*ctypes.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.cometbft.com/v0.38.x/rpc/#/Info/tx_search
func (*Environment) UnconfirmedTxs ¶ added in v0.38.0
func (env *Environment) UnconfirmedTxs(_ *rpctypes.Context, limitPtr *int) (*ctypes.ResultUnconfirmedTxs, error)
UnconfirmedTxs gets unconfirmed transactions (maximum ?limit entries) including their number. More: https://docs.cometbft.com/v0.38.x/rpc/#/Info/unconfirmed_txs
func (*Environment) UnsafeDialPeers ¶ added in v0.38.0
func (env *Environment) UnsafeDialPeers( _ *rpctypes.Context, peers []string, persistent, unconditional, private bool, ) (*ctypes.ResultDialPeers, error)
UnsafeDialPeers dials the given peers (comma-separated id@IP:PORT), optionally making them persistent.
func (*Environment) UnsafeDialSeeds ¶ added in v0.38.0
func (env *Environment) UnsafeDialSeeds(_ *rpctypes.Context, seeds []string) (*ctypes.ResultDialSeeds, error)
UnsafeDialSeeds dials the given seeds (comma-separated id@IP:PORT).
func (*Environment) UnsafeFlushMempool ¶ added in v0.38.0
func (env *Environment) UnsafeFlushMempool(*rpctypes.Context) (*ctypes.ResultUnsafeFlushMempool, error)
UnsafeFlushMempool removes all transactions from the mempool.
func (*Environment) Unsubscribe ¶ added in v0.38.0
func (env *Environment) Unsubscribe(ctx *rpctypes.Context, query string) (*ctypes.ResultUnsubscribe, error)
Unsubscribe from events via WebSocket. More: https://docs.cometbft.com/v0.38.x/rpc/#/Websocket/unsubscribe
func (*Environment) UnsubscribeAll ¶ added in v0.38.0
func (env *Environment) UnsubscribeAll(ctx *rpctypes.Context) (*ctypes.ResultUnsubscribe, error)
UnsubscribeAll from all events via WebSocket. More: https://docs.cometbft.com/v0.38.x/rpc/#/Websocket/unsubscribe_all
func (*Environment) Validators ¶ added in v0.38.0
func (env *Environment) Validators( _ *rpctypes.Context, heightPtr *int64, pagePtr, perPagePtr *int, ) (*ctypes.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.cometbft.com/v0.38.x/rpc/#/Info/validators