referrerpolicy=no-referrer-when-downgrade

Trait sc_network_sync::strategy::SyncingStrategy

source ·
pub trait SyncingStrategy<B>: Send
where B: BlockT,
{
Show 17 methods // Required methods fn add_peer( &mut self, peer_id: PeerId, best_hash: B::Hash, best_number: NumberFor<B>, ); fn remove_peer(&mut self, peer_id: &PeerId); fn on_validated_block_announce( &mut self, is_best: bool, peer_id: PeerId, announce: &BlockAnnounce<B::Header>, ) -> Option<(B::Hash, NumberFor<B>)>; fn set_sync_fork_request( &mut self, peers: Vec<PeerId>, hash: &B::Hash, number: NumberFor<B>, ); fn request_justification(&mut self, hash: &B::Hash, number: NumberFor<B>); fn clear_justification_requests(&mut self); fn on_justification_import( &mut self, hash: B::Hash, number: NumberFor<B>, success: bool, ); fn on_generic_response( &mut self, peer_id: &PeerId, key: StrategyKey, protocol_name: ProtocolName, response: Box<dyn Any + Send>, ); fn on_blocks_processed( &mut self, imported: usize, count: usize, results: Vec<(Result<BlockImportStatus<NumberFor<B>>, BlockImportError>, B::Hash)>, ); fn on_block_finalized(&mut self, hash: &B::Hash, number: NumberFor<B>); fn update_chain_info( &mut self, best_hash: &B::Hash, best_number: NumberFor<B>, ); fn is_major_syncing(&self) -> bool; fn num_peers(&self) -> usize; fn status(&self) -> SyncStatus<B>; fn num_downloaded_blocks(&self) -> usize; fn num_sync_requests(&self) -> usize; fn actions( &mut self, network_service: &NetworkServiceHandle, ) -> Result<Vec<SyncingAction<B>>, ClientError>;
}
Expand description

Syncing strategy for syncing engine to use

Required Methods§

source

fn add_peer( &mut self, peer_id: PeerId, best_hash: B::Hash, best_number: NumberFor<B>, )

Notify syncing state machine that a new sync peer has connected.

source

fn remove_peer(&mut self, peer_id: &PeerId)

Notify that a sync peer has disconnected.

source

fn on_validated_block_announce( &mut self, is_best: bool, peer_id: PeerId, announce: &BlockAnnounce<B::Header>, ) -> Option<(B::Hash, NumberFor<B>)>

Submit a validated block announcement.

Returns new best hash & best number of the peer if they are updated.

source

fn set_sync_fork_request( &mut self, peers: Vec<PeerId>, hash: &B::Hash, number: NumberFor<B>, )

Configure an explicit fork sync request in case external code has detected that there is a stale fork missing.

Note that this function should not be used for recent blocks. Sync should be able to download all the recent forks normally.

Passing empty peers set effectively removes the sync request.

source

fn request_justification(&mut self, hash: &B::Hash, number: NumberFor<B>)

Request extra justification.

source

fn clear_justification_requests(&mut self)

Clear extra justification requests.

source

fn on_justification_import( &mut self, hash: B::Hash, number: NumberFor<B>, success: bool, )

Report a justification import (successful or not).

source

fn on_generic_response( &mut self, peer_id: &PeerId, key: StrategyKey, protocol_name: ProtocolName, response: Box<dyn Any + Send>, )

Process generic response.

Strategy has to create opaque response and should be to downcast it back into concrete type internally. Failure to downcast is an implementation bug.

source

fn on_blocks_processed( &mut self, imported: usize, count: usize, results: Vec<(Result<BlockImportStatus<NumberFor<B>>, BlockImportError>, B::Hash)>, )

A batch of blocks that have been processed, with or without errors.

Call this when a batch of blocks that have been processed by the import queue, with or without errors.

source

fn on_block_finalized(&mut self, hash: &B::Hash, number: NumberFor<B>)

Notify a syncing strategy that a block has been finalized.

source

fn update_chain_info(&mut self, best_hash: &B::Hash, best_number: NumberFor<B>)

Inform sync about a new best imported block.

source

fn is_major_syncing(&self) -> bool

source

fn num_peers(&self) -> usize

Get the number of peers known to the syncing strategy.

source

fn status(&self) -> SyncStatus<B>

Returns the current sync status.

source

fn num_downloaded_blocks(&self) -> usize

Get the total number of downloaded blocks.

source

fn num_sync_requests(&self) -> usize

Get an estimate of the number of parallel sync requests.

source

fn actions( &mut self, network_service: &NetworkServiceHandle, ) -> Result<Vec<SyncingAction<B>>, ClientError>

Get actions that should be performed by the owner on the strategy’s behalf

Implementors§

source§

impl<B, Client> SyncingStrategy<B> for ChainSync<B, Client>
where B: BlockT, Client: HeaderBackend<B> + BlockBackend<B> + HeaderMetadata<B, Error = Error> + ProofProvider<B> + Send + Sync + 'static,

source§

impl<B, Client> SyncingStrategy<B> for PolkadotSyncingStrategy<B, Client>
where B: BlockT, Client: HeaderBackend<B> + BlockBackend<B> + HeaderMetadata<B, Error = Error> + ProofProvider<B> + Send + Sync + 'static,