pub trait BlockImport<B = Block>:
Debug
+ Send
+ Sync {
// Required methods
fn on_new_block(
&mut self,
peer_id: PeerId,
incoming_block: NewBlockEvent<B>,
);
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<BlockImportEvent<B>>;
}
Expand description
Abstraction over block import.
Required Methods§
Sourcefn on_new_block(&mut self, peer_id: PeerId, incoming_block: NewBlockEvent<B>)
fn on_new_block(&mut self, peer_id: PeerId, incoming_block: NewBlockEvent<B>)
Invoked for a received block announcement from the peer.
For a NewBlock
message:
When a
NewBlock
announcement message is received from a peer, the client first verifies the basic header validity of the block, checking whether the proof-of-work value is valid.
For a NewBlockHashes
message, hash announcement should be processed accordingly.
The results are expected to be returned via BlockImport::poll
.
Sourcefn poll(&mut self, cx: &mut Context<'_>) -> Poll<BlockImportEvent<B>>
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<BlockImportEvent<B>>
Returns the results of a BlockImport::on_new_block