pub struct Requester { /* private fields */ }Expand description
Send messages to a node that is running so the node may complete a task.
Implementations§
Source§impl Requester
impl Requester
Sourcepub fn shutdown(&self) -> Result<(), ClientError>
pub fn shutdown(&self) -> Result<(), ClientError>
Sourcepub fn broadcast_tx(&self, tx: TxBroadcast) -> Result<(), ClientError>
pub fn broadcast_tx(&self, tx: TxBroadcast) -> Result<(), ClientError>
Broadcast a new transaction to the network.
§Note
When broadcasting a one-parent one-child (TRUC) package, broadcast the child first, followed by the parent.
Package relay is under-development at the time of writing.
For more information, see BIP-431 and BIP-331.
§Errors
If the node has stopped running.
Sourcepub fn broadcast_random(&self, tx: Transaction) -> Result<(), ClientError>
pub fn broadcast_random(&self, tx: Transaction) -> Result<(), ClientError>
Broadcast a new transaction to the network to a random peer.
§Errors
If the node has stopped running.
Sourcepub async fn broadcast_min_feerate(&self) -> Result<FeeRate, FetchFeeRateError>
pub async fn broadcast_min_feerate(&self) -> Result<FeeRate, FetchFeeRateError>
A connection has a minimum transaction fee requirement to enter its mempool. For proper transaction propagation, transactions should have a fee rate at least as high as the maximum fee filter received. This method returns the maximum fee rate requirement of all connected peers.
For more information, refer to BIP133
§Errors
If the node has stopped running.
Sourcepub async fn get_header(&self, height: u32) -> Result<Header, FetchHeaderError>
pub async fn get_header(&self, height: u32) -> Result<Header, FetchHeaderError>
Sourcepub async fn get_header_range(
&self,
range: Range<u32>,
) -> Result<BTreeMap<u32, Header>, FetchHeaderError>
pub async fn get_header_range( &self, range: Range<u32>, ) -> Result<BTreeMap<u32, Header>, FetchHeaderError>
Sourcepub async fn get_block(
&self,
block_hash: BlockHash,
) -> Result<IndexedBlock, FetchBlockError>
pub async fn get_block( &self, block_hash: BlockHash, ) -> Result<IndexedBlock, FetchBlockError>
Request a block be fetched. Note that this method will request a block from a connected peer’s inventory, and may take an indefinite amount of time, until a peer responds.
§Errors
If the node has stopped running.
Sourcepub fn request_block(
&self,
block_hash: BlockHash,
) -> Result<Receiver<Result<IndexedBlock, FetchBlockError>>, FetchBlockError>
pub fn request_block( &self, block_hash: BlockHash, ) -> Result<Receiver<Result<IndexedBlock, FetchBlockError>>, FetchBlockError>
Request a block be fetched and receive a tokio::sync::oneshot::Receiver
to await the resulting block.
§Errors
If the node has stopped running.
Sourcepub async fn average_fee_rate(
&self,
block_hash: BlockHash,
) -> Result<FeeRate, FetchBlockError>
pub async fn average_fee_rate( &self, block_hash: BlockHash, ) -> Result<FeeRate, FetchBlockError>
Fetch the average fee rate for the given block hash.
Computed by taking (coinbase output amount - block subsidy) / block weight. Note that
this value may provide skewed estimates, as averages are more effected by outliers than
medians. For a rudimentary estimation of the fee rate required to enter the next block,
this method may suffice.
Sourcepub fn rescan(&self) -> Result<(), ClientError>
pub fn rescan(&self) -> Result<(), ClientError>
Starting after the configured checkpoint, re-emit all block filters.
§Errors
If the node has stopped running.
Sourcepub fn set_response_timeout(
&self,
duration: Duration,
) -> Result<(), ClientError>
pub fn set_response_timeout( &self, duration: Duration, ) -> Result<(), ClientError>
Set a new connection timeout for peers to respond to messages.
§Errors
If the node has stopped running.
Sourcepub fn add_peer(&self, peer: impl Into<TrustedPeer>) -> Result<(), ClientError>
pub fn add_peer(&self, peer: impl Into<TrustedPeer>) -> Result<(), ClientError>
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the node is running.