pub trait BlockService {
    type GetBlocksStream: Stream<Item = Result<Block, Error>> + Send + Sync;
    type GetHeadersStream: Stream<Item = Result<Header, Error>> + Send + Sync;
    type PullHeadersStream: Stream<Item = Result<Header, Error>> + Send + Sync;
    type PullBlocksStream: Stream<Item = Result<Block, Error>> + Send + Sync;
    type PullBlocksToTipStream: Stream<Item = Result<Block, Error>> + Send + Sync;
    type SubscriptionStream: Stream<Item = Result<BlockEvent, Error>> + Send + Sync;

    // Required methods
    fn tip<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<Header, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_blocks<'life0, 'async_trait>(
        &'life0 self,
        ids: BlockIds
    ) -> Pin<Box<dyn Future<Output = Result<Self::GetBlocksStream, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_headers<'life0, 'async_trait>(
        &'life0 self,
        ids: BlockIds
    ) -> Pin<Box<dyn Future<Output = Result<Self::GetHeadersStream, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn pull_headers<'life0, 'async_trait>(
        &'life0 self,
        from: BlockIds,
        to: BlockId
    ) -> Pin<Box<dyn Future<Output = Result<Self::PullHeadersStream, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn pull_blocks<'life0, 'async_trait>(
        &'life0 self,
        from: BlockIds,
        to: BlockId
    ) -> Pin<Box<dyn Future<Output = Result<Self::PullBlocksStream, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn pull_blocks_to_tip<'life0, 'async_trait>(
        &'life0 self,
        from: BlockIds
    ) -> Pin<Box<dyn Future<Output = Result<Self::PullBlocksToTipStream, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn push_headers<'life0, 'async_trait>(
        &'life0 self,
        stream: PushStream<Header>
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn upload_blocks<'life0, 'async_trait>(
        &'life0 self,
        stream: PushStream<Block>
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn block_subscription<'life0, 'async_trait>(
        &'life0 self,
        subscriber: Peer,
        stream: PushStream<Header>
    ) -> Pin<Box<dyn Future<Output = Result<Self::SubscriptionStream, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Interface for the blockchain node service implementation responsible for providing access to block data.

Required Associated Types§

source

type GetBlocksStream: Stream<Item = Result<Block, Error>> + Send + Sync

The type of an asynchronous stream that provides blocks in response to get_blocks method.

source

type GetHeadersStream: Stream<Item = Result<Header, Error>> + Send + Sync

The type of an asynchronous stream that provides headers in response to get_headers method.

source

type PullHeadersStream: Stream<Item = Result<Header, Error>> + Send + Sync

The type of an asynchronous stream that provides headers in response to pull_headers method.

source

type PullBlocksStream: Stream<Item = Result<Block, Error>> + Send + Sync

The type of an asynchronous stream that provides blocks in responce to pull_blocks method.

source

type PullBlocksToTipStream: Stream<Item = Result<Block, Error>> + Send + Sync

The type of an asynchronous stream that provides blocks in response to pull_blocks_to_tip method.

source

type SubscriptionStream: Stream<Item = Result<BlockEvent, Error>> + Send + Sync

The type of outbound asynchronous streams returned by the subscription method.

Required Methods§

source

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

Serves a request for the current blockchain tip. Resolves to the tip of the blockchain accepted by this node.

source

fn get_blocks<'life0, 'async_trait>( &'life0 self, ids: BlockIds ) -> Pin<Box<dyn Future<Output = Result<Self::GetBlocksStream, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Serves a request to retrieve blocks identified by the list of ids Resloves to a stream of blocks to send to the remote client peer.

source

fn get_headers<'life0, 'async_trait>( &'life0 self, ids: BlockIds ) -> Pin<Box<dyn Future<Output = Result<Self::GetHeadersStream, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Serves a request to retrieve block headers identified by the list of ids Resloves to a stream of headers to send to the remote client peer.

source

fn pull_headers<'life0, 'async_trait>( &'life0 self, from: BlockIds, to: BlockId ) -> Pin<Box<dyn Future<Output = Result<Self::PullHeadersStream, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Get blocks, walking forward in a range between either of the given starting points, and the ending point.

source

fn pull_blocks<'life0, 'async_trait>( &'life0 self, from: BlockIds, to: BlockId ) -> Pin<Box<dyn Future<Output = Result<Self::PullBlocksStream, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Stream all blocks from the given range.

source

fn pull_blocks_to_tip<'life0, 'async_trait>( &'life0 self, from: BlockIds ) -> Pin<Box<dyn Future<Output = Result<Self::PullBlocksToTipStream, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Stream blocks from the first of the given starting points that is found in the node’s chain, to the chain’s tip.

source

fn push_headers<'life0, 'async_trait>( &'life0 self, stream: PushStream<Header> ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Called by the protocol implementation to handle a stream of block headers sent by the peer in response to a BlockEvent::Missing solicitation.

source

fn upload_blocks<'life0, 'async_trait>( &'life0 self, stream: PushStream<Block> ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Called by the protocol implementation to handle a stream of blocks sent by the peer in response to a BlockEvent::Solicit solicitation.

source

fn block_subscription<'life0, 'async_trait>( &'life0 self, subscriber: Peer, stream: PushStream<Header> ) -> Pin<Box<dyn Future<Output = Result<Self::SubscriptionStream, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Called by the protocol implementation to establish a bidirectional subscription stream. The inbound stream is passed to the asynchronous method, which resolves to the outbound stream.

Implementors§