Trait chain_network::core::server::block::BlockService
source · 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§
sourcetype GetBlocksStream: Stream<Item = Result<Block, Error>> + Send + Sync
type GetBlocksStream: Stream<Item = Result<Block, Error>> + Send + Sync
The type of an asynchronous stream that provides blocks in
response to get_blocks
method.
sourcetype GetHeadersStream: Stream<Item = Result<Header, Error>> + Send + Sync
type GetHeadersStream: Stream<Item = Result<Header, Error>> + Send + Sync
The type of an asynchronous stream that provides headers in
response to get_headers
method.
sourcetype PullHeadersStream: Stream<Item = Result<Header, Error>> + Send + Sync
type PullHeadersStream: Stream<Item = Result<Header, Error>> + Send + Sync
The type of an asynchronous stream that provides headers in
response to pull_headers
method.
sourcetype PullBlocksStream: Stream<Item = Result<Block, Error>> + Send + Sync
type PullBlocksStream: Stream<Item = Result<Block, Error>> + Send + Sync
The type of an asynchronous stream that provides blocks in responce to
pull_blocks
method.
sourcetype PullBlocksToTipStream: Stream<Item = Result<Block, Error>> + Send + Sync
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.
sourcetype SubscriptionStream: Stream<Item = Result<BlockEvent, Error>> + Send + Sync
type SubscriptionStream: Stream<Item = Result<BlockEvent, Error>> + Send + Sync
The type of outbound asynchronous streams returned by the
subscription
method.
Required Methods§
sourcefn 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 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.
sourcefn 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_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.
sourcefn 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 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.
sourcefn 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_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.
sourcefn 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<'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.
sourcefn 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 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.
sourcefn 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 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.
sourcefn 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 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.
sourcefn 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,
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.