[][src]Enum zebra_network::Request

pub enum Request {
    FindBlocks {
        known_blocks: Vec<BlockHeaderHash>,
        stop: Option<BlockHeaderHash>,
    // some variants omitted

A network request, represented in internal format.

The network layer aims to abstract away the details of the Bitcoin wire protocol into a clear request/response API. Each Request documents the possible Responses it can generate; it is fine (and recommended!) to match on the expected responses and treat the others as unreachable!(), since their return indicates a bug in the network code.



Requests additional peers from the server.


Returns Response::Peers.


Request block data by block hashes.

This uses a HashSet rather than a Vec for two reasons. First, it automatically deduplicates the requested blocks. Second, the internal protocol translator needs to maintain a HashSet anyways, in order to keep track of which requested blocks have been received and when the request is ready. Rather than force the internals to always convert into a HashSet, we require the caller to pass one, so that if the caller didn't start with a Vec but with, e.g., an iterator, they can collect directly into a HashSet and save work.


Returns Response::Blocks.


Request block hashes of subsequent blocks in the chain, giving hashes of known blocks.


Returns Response::BlockHeaderHashes.


This is implemented by sending a getblocks message. Bitcoin nodes respond to getblocks with an inv message containing a list of the subsequent blocks. However, Bitcoin nodes also send inv messages unsolicited in order to gossip new blocks to their peers. These gossip messages can race with the response to a getblocks request, and there is no way for the network layer to distinguish them. For this reason, the response may occasionally contain a single hash of a new chain tip rather than a list of hashes of subsequent blocks. We believe that unsolicited inv messages will always have exactly one block hash.

Fields of FindBlocks

known_blocks: Vec<BlockHeaderHash>

Hashes of known blocks, ordered from highest height to lowest height.

stop: Option<BlockHeaderHash>

Optionally, the last header to request.

Trait Implementations

impl Clone for Request[src]

impl Debug for Request[src]

Auto Trait Implementations

impl RefUnwindSafe for Request

impl Send for Request

impl Sync for Request

impl Unpin for Request

impl UnwindSafe for Request

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

impl<T> WithSubscriber for T[src]