Trait sc_network_sync::strategy::SyncingStrategy
source · pub trait SyncingStrategy<B>: Sendwhere
B: BlockT,{
Show 19 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_block_response(
&mut self,
peer_id: PeerId,
key: StrategyKey,
request: BlockRequest<B>,
blocks: Vec<BlockData<B>>,
);
fn on_state_response(
&mut self,
peer_id: PeerId,
key: StrategyKey,
response: OpaqueStateResponse,
);
fn on_warp_proof_response(
&mut self,
peer_id: &PeerId,
key: StrategyKey,
response: EncodedProof,
);
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) -> Result<Vec<SyncingAction<B>>, ClientError>;
}
Expand description
Syncing strategy for syncing engine to use
Required Methods§
sourcefn add_peer(
&mut self,
peer_id: PeerId,
best_hash: B::Hash,
best_number: NumberFor<B>,
)
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.
sourcefn remove_peer(&mut self, peer_id: &PeerId)
fn remove_peer(&mut self, peer_id: &PeerId)
Notify that a sync peer has disconnected.
sourcefn on_validated_block_announce(
&mut self,
is_best: bool,
peer_id: PeerId,
announce: &BlockAnnounce<B::Header>,
) -> Option<(B::Hash, NumberFor<B>)>
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.
sourcefn set_sync_fork_request(
&mut self,
peers: Vec<PeerId>,
hash: &B::Hash,
number: NumberFor<B>,
)
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.
sourcefn request_justification(&mut self, hash: &B::Hash, number: NumberFor<B>)
fn request_justification(&mut self, hash: &B::Hash, number: NumberFor<B>)
Request extra justification.
sourcefn clear_justification_requests(&mut self)
fn clear_justification_requests(&mut self)
Clear extra justification requests.
sourcefn on_justification_import(
&mut self,
hash: B::Hash,
number: NumberFor<B>,
success: bool,
)
fn on_justification_import( &mut self, hash: B::Hash, number: NumberFor<B>, success: bool, )
Report a justification import (successful or not).
sourcefn on_block_response(
&mut self,
peer_id: PeerId,
key: StrategyKey,
request: BlockRequest<B>,
blocks: Vec<BlockData<B>>,
)
fn on_block_response( &mut self, peer_id: PeerId, key: StrategyKey, request: BlockRequest<B>, blocks: Vec<BlockData<B>>, )
Process block response.
sourcefn on_state_response(
&mut self,
peer_id: PeerId,
key: StrategyKey,
response: OpaqueStateResponse,
)
fn on_state_response( &mut self, peer_id: PeerId, key: StrategyKey, response: OpaqueStateResponse, )
Process state response.
sourcefn on_warp_proof_response(
&mut self,
peer_id: &PeerId,
key: StrategyKey,
response: EncodedProof,
)
fn on_warp_proof_response( &mut self, peer_id: &PeerId, key: StrategyKey, response: EncodedProof, )
Process warp proof response.
sourcefn on_blocks_processed(
&mut self,
imported: usize,
count: usize,
results: Vec<(Result<BlockImportStatus<NumberFor<B>>, BlockImportError>, B::Hash)>,
)
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.
sourcefn on_block_finalized(&mut self, hash: &B::Hash, number: NumberFor<B>)
fn on_block_finalized(&mut self, hash: &B::Hash, number: NumberFor<B>)
Notify a syncing strategy that a block has been finalized.
sourcefn update_chain_info(&mut self, best_hash: &B::Hash, best_number: NumberFor<B>)
fn update_chain_info(&mut self, best_hash: &B::Hash, best_number: NumberFor<B>)
Inform sync about a new best imported block.
fn is_major_syncing(&self) -> bool
sourcefn status(&self) -> SyncStatus<B>
fn status(&self) -> SyncStatus<B>
Returns the current sync status.
sourcefn num_downloaded_blocks(&self) -> usize
fn num_downloaded_blocks(&self) -> usize
Get the total number of downloaded blocks.
sourcefn num_sync_requests(&self) -> usize
fn num_sync_requests(&self) -> usize
Get an estimate of the number of parallel sync requests.
sourcefn actions(&mut self) -> Result<Vec<SyncingAction<B>>, ClientError>
fn actions(&mut self) -> Result<Vec<SyncingAction<B>>, ClientError>
Get actions that should be performed by the owner on the strategy’s behalf