zebra_rpc::methods::get_block_template_rpcs

Trait GetBlockTemplateRpcServer

source
pub trait GetBlockTemplateRpcServer:
    Sized
    + Send
    + Sync
    + 'static {
Show 15 methods // Required methods fn get_block_count(&self) -> Result<u32>; fn get_block_hash<'life0, 'async_trait>( &'life0 self, index: i32, ) -> Pin<Box<dyn Future<Output = Result<GetBlockHash>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_block_template<'life0, 'async_trait>( &'life0 self, parameters: Option<JsonParameters>, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn submit_block<'life0, 'async_trait>( &'life0 self, hex_data: HexData, _parameters: Option<JsonParameters>, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_mining_info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_network_sol_ps<'life0, 'async_trait>( &'life0 self, num_blocks: Option<i32>, height: Option<i32>, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_peer_info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<PeerInfo>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn validate_address<'life0, 'async_trait>( &'life0 self, address: String, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn z_validate_address<'life0, 'async_trait>( &'life0 self, address: String, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_block_subsidy<'life0, 'async_trait>( &'life0 self, height: Option<u32>, ) -> Pin<Box<dyn Future<Output = Result<BlockSubsidy>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_difficulty<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<f64>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn z_list_unified_receivers<'life0, 'async_trait>( &'life0 self, address: String, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn generate<'life0, 'async_trait>( &'life0 self, num_blocks: u32, ) -> Pin<Box<dyn Future<Output = Result<Vec<GetBlockHash>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; // Provided methods fn get_network_hash_ps<'life0, 'async_trait>( &'life0 self, num_blocks: Option<i32>, height: Option<i32>, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn into_rpc(self) -> RpcModule<Self> { ... }
}
Expand description

Server trait implementation for the GetBlockTemplateRpc RPC API.

Required Methods§

source

fn get_block_count(&self) -> Result<u32>

Returns the height of the most recent block in the best valid block chain (equivalently, the number of blocks in this chain excluding the genesis block).

zcashd reference: getblockcount method: post tags: blockchain

§Notes

This rpc method is available only if zebra is built with --features getblocktemplate-rpcs.

source

fn get_block_hash<'life0, 'async_trait>( &'life0 self, index: i32, ) -> Pin<Box<dyn Future<Output = Result<GetBlockHash>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the hash of the block of a given height iff the index argument correspond to a block in the best chain.

zcashd reference: getblockhash method: post tags: blockchain

§Parameters
  • index: (numeric, required, example=1) The block index.
§Notes
  • If index is positive then index = block height.
  • If index is negative then -1 is the last known valid block.
  • This rpc method is available only if zebra is built with --features getblocktemplate-rpcs.
source

fn get_block_template<'life0, 'async_trait>( &'life0 self, parameters: Option<JsonParameters>, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns a block template for mining new Zcash blocks.

§Parameters
  • jsonrequestobject: (string, optional) A JSON object containing arguments.

zcashd reference: getblocktemplate method: post tags: mining

§Notes

Arguments to this RPC are currently ignored. Long polling, block proposals, server lists, and work IDs are not supported.

Miners can make arbitrary changes to blocks, as long as:

  • the data sent to submitblock is a valid Zcash block, and
  • the parent block is a valid block that Zebra already has, or will receive soon.

Zebra verifies blocks in parallel, and keeps recent chains in parallel, so moving between chains and forking chains is very cheap.

This rpc method is available only if zebra is built with --features getblocktemplate-rpcs.

source

fn submit_block<'life0, 'async_trait>( &'life0 self, hex_data: HexData, _parameters: Option<JsonParameters>, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Submits block to the node to be validated and committed. Returns the submit_block::Response for the operation, as a JSON string.

zcashd reference: submitblock method: post tags: mining

§Parameters
  • hexdata: (string, required)
  • jsonparametersobject: (string, optional) - currently ignored
§Notes
  • jsonparametersobject holds a single field, workid, that must be included in submissions if provided by the server.
source

fn get_mining_info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns mining-related information.

zcashd reference: getmininginfo method: post tags: mining

source

fn get_network_sol_ps<'life0, 'async_trait>( &'life0 self, num_blocks: Option<i32>, height: Option<i32>, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the estimated network solutions per second based on the last num_blocks before height.

If num_blocks is not supplied, uses 120 blocks. If it is 0 or -1, uses the difficulty averaging window. If height is not supplied or is -1, uses the tip height.

zcashd reference: getnetworksolps method: post tags: mining

source

fn get_peer_info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<PeerInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns data about each connected network node.

zcashd reference: getpeerinfo method: post tags: network

source

fn validate_address<'life0, 'async_trait>( &'life0 self, address: String, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Checks if a zcash address is valid. Returns information about the given address if valid.

zcashd reference: validateaddress method: post tags: util

§Parameters
  • address: (string, required) The zcash address to validate.
§Notes
  • No notes
source

fn z_validate_address<'life0, 'async_trait>( &'life0 self, address: String, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Checks if a zcash address is valid. Returns information about the given address if valid.

zcashd reference: z_validateaddress method: post tags: util

§Parameters
  • address: (string, required) The zcash address to validate.
§Notes
  • No notes
source

fn get_block_subsidy<'life0, 'async_trait>( &'life0 self, height: Option<u32>, ) -> Pin<Box<dyn Future<Output = Result<BlockSubsidy>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the block subsidy reward of the block at height, taking into account the mining slow start. Returns an error if height is less than the height of the first halving for the current network.

zcashd reference: getblocksubsidy method: post tags: mining

§Parameters
  • height: (numeric, optional, example=1) Can be any valid current or future height.
§Notes

If height is not supplied, uses the tip height.

source

fn get_difficulty<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<f64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the proof-of-work difficulty as a multiple of the minimum difficulty.

zcashd reference: getdifficulty method: post tags: blockchain

source

fn z_list_unified_receivers<'life0, 'async_trait>( &'life0 self, address: String, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the list of individual payment addresses given a unified address.

zcashd reference: z_listunifiedreceivers method: post tags: wallet

§Parameters
  • address: (string, required) The zcash unified address to get the list from.
§Notes
  • No notes
source

fn generate<'life0, 'async_trait>( &'life0 self, num_blocks: u32, ) -> Pin<Box<dyn Future<Output = Result<Vec<GetBlockHash>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mine blocks immediately. Returns the block hashes of the generated blocks.

§Parameters
  • num_blocks: (numeric, required, example=1) Number of blocks to be generated.
§Notes

Only works if the network of the running zebrad process is Regtest.

zcashd reference: generate method: post tags: generating

Provided Methods§

source

fn get_network_hash_ps<'life0, 'async_trait>( &'life0 self, num_blocks: Option<i32>, height: Option<i32>, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the estimated network solutions per second based on the last num_blocks before height.

This method name is deprecated, use getnetworksolps instead. See that method for details.

zcashd reference: getnetworkhashps method: post tags: mining

source

fn into_rpc(self) -> RpcModule<Self>

Collects all the methods and subscriptions defined in the trait and adds them into a single RpcModule.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Mempool, State, Tip, BlockVerifierRouter, SyncStatus, AddressBook> GetBlockTemplateRpcServer for GetBlockTemplateRpcImpl<Mempool, State, Tip, BlockVerifierRouter, SyncStatus, AddressBook>
where Mempool: Service<Request, Response = Response, Error = BoxError> + Clone + Send + Sync + 'static, Mempool::Future: Send, State: Service<ReadRequest, Response = ReadResponse, Error = BoxError> + Clone + Send + Sync + 'static, <State as Service<ReadRequest>>::Future: Send, Tip: ChainTip + Clone + Send + Sync + 'static, BlockVerifierRouter: Service<Request, Response = Hash, Error = BoxError> + Clone + Send + Sync + 'static, <BlockVerifierRouter as Service<Request>>::Future: Send, SyncStatus: ChainSyncStatus + Clone + Send + Sync + 'static, AddressBook: AddressBookPeers + Clone + Send + Sync + 'static,