core

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

README

Tendermint RPC

Pagination

Requests that return multiple items will be paginated to 30 items by default. You can specify further pages with the ?page parameter. You can also set a custom page size up to 100 with the ?per_page parameter.

Subscribing to events

The user can subscribe to events emitted by Tendermint, using /subscribe. If the maximum number of clients is reached or the client has too many subscriptions, an error will be returned. The subscription timeout is 5 sec. Each subscription has a buffer to accommodate short bursts of events or some slowness in clients. If the buffer gets full, the subscription will be canceled ("client is not pulling messages fast enough"). If Tendermint exits, all subscriptions are canceled ("Tendermint exited"). The user can unsubscribe using either /unsubscribe or /unsubscribe_all.

Documentation

Overview

Package core defines the Tendermint RPC endpoints.

Tendermint ships with its own JSONRPC library - https://github.com/tendermint/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

View Source
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   consensusState
	ConsensusReactor consensusReactor
	P2PPeers         peers

	// Legacy p2p stack
	P2PTransport transport

	// interfaces for new p2p interfaces
	PeerManager peerManager

	// objects
	PubKey            crypto.PubKey
	GenDoc            *types.GenesisDoc // cache the genesis structure
	EventSinks        []indexer.EventSink
	EventBus          *types.EventBus // thread safe
	Mempool           mempool.Mempool
	BlockSyncReactor  consensus.BlockSyncReactor
	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 *rpctypes.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 *rpctypes.Context,
	path string,
	data bytes.HexBytes,
	height int64,
	prove bool,
) (*coretypes.ResultABCIQuery, error)

ABCIQuery queries the application for some information. More: https://docs.tendermint.com/master/rpc/#/ABCI/abci_query

func (*Environment) AddUnsafe

func (env *Environment) AddUnsafe(routes RoutesMap)

AddUnsafeRoutes adds unsafe routes.

func (*Environment) Block

func (env *Environment) Block(ctx *rpctypes.Context, heightPtr *int64) (*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 *rpctypes.Context, hash bytes.HexBytes) (*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 *rpctypes.Context, heightPtr *int64) (*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. Thus response.results.deliver_tx[5] is the results of executing getBlock(h).Txs[5] More: https://docs.tendermint.com/master/rpc/#/Info/block_results

func (*Environment) BlockSearch

func (env *Environment) BlockSearch(
	ctx *rpctypes.Context,
	query string,
	pagePtr, perPagePtr *int,
	orderBy string,
) (*coretypes.ResultBlockSearch, error)

BlockSearch searches for a paginated set of blocks matching BeginBlock and EndBlock event search criteria.

func (*Environment) BlockchainInfo

func (env *Environment) BlockchainInfo(
	ctx *rpctypes.Context,
	minHeight, maxHeight int64) (*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 *rpctypes.Context,
	ev types.Evidence) (*coretypes.ResultBroadcastEvidence, error)

BroadcastEvidence broadcasts evidence of the misbehavior. More: https://docs.tendermint.com/master/rpc/#/Evidence/broadcast_evidence

func (*Environment) BroadcastTxAsync

func (env *Environment) BroadcastTxAsync(ctx *rpctypes.Context, tx types.Tx) (*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

func (*Environment) BroadcastTxCommit

func (env *Environment) BroadcastTxCommit(ctx *rpctypes.Context, tx types.Tx) (*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 *rpctypes.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error)

BroadcastTxSync 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) CheckTx

func (env *Environment) CheckTx(ctx *rpctypes.Context, tx types.Tx) (*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 *rpctypes.Context, heightPtr *int64) (*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 *rpctypes.Context,
	heightPtr *int64) (*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 *rpctypes.Context) (*coretypes.ResultDumpConsensusState, error)

DumpConsensusState dumps consensus state. UNSTABLE More: https://docs.tendermint.com/master/rpc/#/Info/dump_consensus_state

func (*Environment) Genesis

func (env *Environment) Genesis(ctx *rpctypes.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 *rpctypes.Context, chunk uint) (*coretypes.ResultGenesisChunk, error)

func (*Environment) GetConsensusState

func (env *Environment) GetConsensusState(ctx *rpctypes.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) GetRoutes

func (env *Environment) GetRoutes() RoutesMap

Routes is a map of available routes.

func (*Environment) Health

func (env *Environment) Health(ctx *rpctypes.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 *rpctypes.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 *rpctypes.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 *rpctypes.Context, txkey types.TxKey) error

func (*Environment) Status

func (env *Environment) Status(ctx *rpctypes.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 *rpctypes.Context, query string) (*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 *rpctypes.Context, hash bytes.HexBytes, prove bool) (*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 *rpctypes.Context,
	query string,
	prove bool,
	pagePtr, perPagePtr *int,
	orderBy string,
) (*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 *rpctypes.Context, limitPtr *int) (*coretypes.ResultUnconfirmedTxs, error)

UnconfirmedTxs gets unconfirmed transactions (maximum ?limit entries) including their number. More: https://docs.tendermint.com/master/rpc/#/Info/unconfirmed_txs

func (*Environment) UnsafeDialPeers

func (env *Environment) UnsafeDialPeers(
	ctx *rpctypes.Context,
	peers []string,
	persistent, unconditional, private bool) (*coretypes.ResultDialPeers, error)

UnsafeDialPeers dials the given peers (comma-separated id@IP:PORT), optionally making them persistent.

func (*Environment) UnsafeDialSeeds

func (env *Environment) UnsafeDialSeeds(ctx *rpctypes.Context, seeds []string) (*coretypes.ResultDialSeeds, error)

UnsafeDialSeeds dials the given seeds (comma-separated id@IP:PORT).

func (*Environment) UnsafeFlushMempool

func (env *Environment) UnsafeFlushMempool(ctx *rpctypes.Context) (*coretypes.ResultUnsafeFlushMempool, error)

UnsafeFlushMempool removes all transactions from the mempool.

func (*Environment) Unsubscribe

func (env *Environment) Unsubscribe(ctx *rpctypes.Context, query string) (*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 *rpctypes.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 *rpctypes.Context,
	heightPtr *int64,
	pagePtr, perPagePtr *int) (*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 RoutesMap

type RoutesMap map[string]*rpc.RPCFunc

Jump to

Keyboard shortcuts

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