rpc

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2023 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotFound = errors.New("not found")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	////// Chain
	// GetTipBlockNumber returns the number of blocks in the longest blockchain.
	GetTipBlockNumber(ctx context.Context) (uint64, error)

	// GetTipHeader returns the information about the tip header of the longest.
	GetTipHeader(ctx context.Context) (*types.Header, error)

	// GetCurrentEpoch returns the information about the current epoch.
	GetCurrentEpoch(ctx context.Context) (*types.Epoch, error)

	// GetEpochByNumber return the information corresponding the given epoch number.
	GetEpochByNumber(ctx context.Context, number uint64) (*types.Epoch, error)

	// GetBlockHash returns the hash of a block in the best-block-chain by block number; block of No.0 is the genesis block.
	GetBlockHash(ctx context.Context, number uint64) (*types.Hash, error)

	// GetBlock returns the information about a block by hash.
	GetBlock(ctx context.Context, hash types.Hash) (*types.Block, error)

	// GetBlockVerbosity0 returns the information about a block by hash, but with verbosity specified to 0.
	GetPackedBlock(ctx context.Context, hash types.Hash) (*types.Block, error)

	// GetBlockWithCycles returns the information about a block by hash(with cycles info).
	GetBlockWithCycles(ctx context.Context, hash types.Hash) (*types.BlockWithCycles, error)

	// GetBlockWithCyclesVerbosity0 returns the information about a block by hash(with cycles info), but with verbosity specified to 0.
	GetPackedBlockWithCycles(ctx context.Context, hash types.Hash) (*types.BlockWithCycles, error)

	// GetHeader returns the information about a block header by hash.
	GetHeader(ctx context.Context, hash types.Hash) (*types.Header, error)

	// GetHeaderVerbosity0 returns the information about a block header by hash, but with verbosity specified to 0.
	GetPackedHeader(ctx context.Context, hash types.Hash) (*types.Header, error)

	// GetHeaderByNumber returns the information about a block header by block number.
	GetHeaderByNumber(ctx context.Context, number uint64) (*types.Header, error)

	// GetHeaderByNumberVerbosity0 returns the information about a block header by block number.
	GetPackedHeaderByNumber(ctx context.Context, number uint64) (*types.Header, error)
	// GetLiveCell returns the information about a cell by out_point if it is live.
	// If second with_data argument set to true, will return cell data and data_hash if it is live.
	GetLiveCell(ctx context.Context, outPoint *types.OutPoint, withData bool) (*types.CellWithStatus, error)

	// GetTransaction returns the information about a transaction requested by transaction hash.
	GetTransaction(ctx context.Context, hash types.Hash) (*types.TransactionWithStatus, error)

	// GetBlockEconomicState return block economic state, It includes the rewards details and when it is finalized.
	GetBlockEconomicState(ctx context.Context, hash types.Hash) (*types.BlockEconomicState, error)

	// GetTransactionProof Returns a Merkle proof that transactions are included in a block.
	GetTransactionProof(ctx context.Context, txHashes []string, blockHash *types.Hash) (*types.TransactionProof, error)

	//VerifyTransactionProof verifies that a proof points to transactions in a block, returning the transaction hashes it commits to.
	VerifyTransactionProof(ctx context.Context, proof *types.TransactionProof) ([]*types.Hash, error)

	// GetBlockByNumber get block by number
	GetBlockByNumber(ctx context.Context, number uint64) (*types.Block, error)

	// GetBlockByNumber get block by number
	GetBlockByNumberWithCycles(ctx context.Context, number uint64) (*types.BlockWithCycles, error)

	// GetForkBlock The RPC returns a fork block or null. When the RPC returns a block, the block hash must equal to the parameter block_hash.
	GetForkBlock(ctx context.Context, blockHash types.Hash) (*types.Block, error)

	// GetConsensus Return various consensus parameters.
	GetConsensus(ctx context.Context) (*types.Consensus, error)

	// GetBlockMedianTime When the given block hash is not on the current canonical chain, this RPC returns null;
	// otherwise returns the median time of the consecutive 37 blocks where the given block_hash has the highest height.
	// Note that the given block is included in the median time. The included block number range is [MAX(block - 36, 0), block].
	GetBlockMedianTime(ctx context.Context, blockHash types.Hash) (uint64, error)

	// GetFeeRateStatics Returns the fee_rate statistics of confirmed blocks on the chain
	GetFeeRateStatics(ctx context.Context, target interface{}) (*types.FeeRateStatics, error)

	////// Experiment
	// DryRunTransaction dry run transaction and return the execution cycles.
	// This method will not check the transaction validity,
	// but only run the lock script and type script and then return the execution cycles.
	// Used to debug transaction scripts and query how many cycles the scripts consume.
	// Deprecated
	DryRunTransaction(ctx context.Context, transaction *types.Transaction) (*types.DryRunTransactionResult, error)

	EstimateCycles(ctx context.Context, transaction *types.Transaction) (*types.EstimateCycles, error)

	// CalculateDaoMaximumWithdraw calculate the maximum withdraw one can get, given a referenced DAO cell, and a withdraw block hash.
	CalculateDaoMaximumWithdraw(ctx context.Context, point *types.OutPoint, hash types.Hash) (uint64, error)

	////// Net
	// LocalNodeInfo returns the local node information.
	LocalNodeInfo(ctx context.Context) (*types.LocalNode, error)

	// GetPeers returns the connected peers information.
	GetPeers(ctx context.Context) ([]*types.RemoteNode, error)

	// GetBannedAddresses returns all banned IPs/Subnets.
	GetBannedAddresses(ctx context.Context) ([]*types.BannedAddress, error)

	// ClearBannedAddress returns all banned IPs/Subnets.
	ClearBannedAddresses(ctx context.Context) error

	// SetBan insert or delete an IP/Subnet from the banned list
	SetBan(ctx context.Context, address string, command string, banTime uint64, absolute bool, reason string) error

	// SyncState returns chain synchronization state of this node.
	SyncState(ctx context.Context) (*types.SyncState, error)

	// SetNetworkActive state - true to enable networking, false to disable
	SetNetworkActive(ctx context.Context, state bool) error

	// AddNode Attempts to add a node to the peers list and try connecting to it
	AddNode(ctx context.Context, peerId, address string) error

	// RemoveNode Attempts to remove a node from the peers list and try disconnecting from it.
	RemoveNode(ctx context.Context, peerId string) error

	// PingPeers Requests that a ping is sent to all connected peers, to measure ping time.
	PingPeers(ctx context.Context) error

	////// Pool
	// SendTransaction send new transaction into transaction pool.
	SendTransaction(ctx context.Context, tx *types.Transaction) (*types.Hash, error)

	// TxPoolInfo return the transaction pool information
	TxPoolInfo(ctx context.Context) (*types.TxPoolInfo, error)

	// GetRawTxPool Returns all transaction ids in tx pool as a json array of string transaction ids.
	GetRawTxPool(ctx context.Context) (*types.RawTxPool, error)

	// ClearTxPool Removes all transactions from the transaction pool.
	ClearTxPool(ctx context.Context) error

	////// Stats
	// GetBlockchainInfo return state info of blockchain
	GetBlockchainInfo(ctx context.Context) (*types.BlockchainInfo, error)

	////// Batch
	BatchTransactions(ctx context.Context, batch []types.BatchTransactionItem) error

	// Batch Live cells
	BatchLiveCells(ctx context.Context, batch []types.BatchLiveCellItem) error

	// GetCells returns the live cells collection by the lock or type script.
	GetCells(ctx context.Context, searchKey *indexer.SearchKey, order indexer.SearchOrder, limit uint64, afterCursor string) (*indexer.LiveCells, error)

	// GetTransactions returns the transactions collection by the lock or type script.
	GetTransactions(ctx context.Context, searchKey *indexer.SearchKey, order indexer.SearchOrder, limit uint64, afterCursor string) (*indexer.TxsWithCell, error)

	// GetTransactionsGrouped returns the grouped transactions collection by the lock or type script.
	GetTransactionsGrouped(ctx context.Context, searchKey *indexer.SearchKey, order indexer.SearchOrder, limit uint64, afterCursor string) (*indexer.TxsWithCells, error)

	//GetTip returns the latest height processed by indexer
	GetIndexerTip(ctx context.Context) (*indexer.TipHeader, error)

	//GetCellsCapacity returns the live cells capacity by the lock or type script.
	GetCellsCapacity(ctx context.Context, searchKey *indexer.SearchKey) (*indexer.Capacity, error)

	// Close close client
	Close()

	CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
}

Client for the Nervos RPC API.

func Dial

func Dial(url string) (Client, error)

func DialContext

func DialContext(ctx context.Context, url string) (Client, error)

func NewClient

func NewClient(c *rpc.Client) Client

Jump to

Keyboard shortcuts

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