Requester

Struct Requester 

Source
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

Source

pub fn shutdown(&self) -> Result<(), ClientError>

Tell the node to shut down.

§Errors

If the node has already stopped running.

Source

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.

Source

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.

Source

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.

Source

pub async fn get_header(&self, height: u32) -> Result<Header, FetchHeaderError>

Get a header at the specified height, if it exists.

§Note

The height of the chain is the canonical index of the header in the chain. For example, the genesis block is at a height of zero.

§Errors

If the node has stopped running.

Source

pub async fn get_header_range( &self, range: Range<u32>, ) -> Result<BTreeMap<u32, Header>, FetchHeaderError>

Get a range of headers by the specified range.

§Errors

If the node has stopped running.

Source

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.

Source

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.

Source

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.

Source

pub fn rescan(&self) -> Result<(), ClientError>

Starting after the configured checkpoint, re-emit all block filters.

§Errors

If the node has stopped running.

Source

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.

Source

pub fn add_peer(&self, peer: impl Into<TrustedPeer>) -> Result<(), ClientError>

Add another known peer to connect to.

§Errors

If the node has stopped running.

Source

pub fn is_running(&self) -> bool

Check if the node is running.

Trait Implementations§

Source§

impl Clone for Requester

Source§

fn clone(&self) -> Requester

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Requester

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V