Trait BlockImport
pub trait BlockImport:
Debug
+ Send
+ Sync {
// Required methods
fn on_new_block(
&mut self,
peer_id: FixedBytes<64>,
incoming_block: NewBlockMessage,
);
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<BlockImportOutcome>;
}
Expand description
Abstraction over block import.
Required Methods§
fn on_new_block(
&mut self,
peer_id: FixedBytes<64>,
incoming_block: NewBlockMessage,
)
fn on_new_block( &mut self, peer_id: FixedBytes<64>, incoming_block: NewBlockMessage, )
Invoked for a received NewBlock
broadcast message from the peer.
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.
This is supposed to start verification. The results are then expected to be returned via
BlockImport::poll
.
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<BlockImportOutcome>
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<BlockImportOutcome>
Returns the results of a BlockImport::on_new_block