mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-11 06:57:21 +00:00
Move import queue out of sc-network (#12764)
* Move import queue out of `sc-network` Add supplementary asynchronous API for the import queue which means it can be run as an independent task and communicated with through the `ImportQueueService`. This commit removes removes block and justification imports from `sc-network` and provides `ChainSync` with a handle to import queue so it can import blocks and justifications. Polling of the import queue is moved complete out of `sc-network` and `sc_consensus::Link` is implemented for `ChainSyncInterfaceHandled` so the import queue can still influence the syncing process. * Fix tests * Apply review comments * Apply suggestions from code review Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/sync/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
use futures::channel::oneshot;
|
||||
use libp2p::{Multiaddr, PeerId};
|
||||
use sc_consensus::{BlockImportError, BlockImportStatus};
|
||||
use sc_network_common::{
|
||||
config::MultiaddrWithPeerId,
|
||||
protocol::ProtocolName,
|
||||
@@ -29,13 +30,43 @@ use sp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
use std::collections::HashSet;
|
||||
|
||||
mockall::mock! {
|
||||
pub ChainSyncInterface<B: BlockT> {}
|
||||
pub ChainSyncInterface<B: BlockT> {
|
||||
pub fn justification_sync_link_request_justification(&self, hash: &B::Hash, number: NumberFor<B>);
|
||||
pub fn justification_sync_link_clear_justification_requests(&self);
|
||||
}
|
||||
|
||||
impl<B: BlockT + 'static> NetworkSyncForkRequest<B::Hash, NumberFor<B>>
|
||||
for ChainSyncInterface<B>
|
||||
{
|
||||
fn set_sync_fork_request(&self, peers: Vec<PeerId>, hash: B::Hash, number: NumberFor<B>);
|
||||
}
|
||||
|
||||
impl<B: BlockT> sc_consensus::Link<B> for ChainSyncInterface<B> {
|
||||
fn blocks_processed(
|
||||
&mut self,
|
||||
imported: usize,
|
||||
count: usize,
|
||||
results: Vec<(Result<BlockImportStatus<NumberFor<B>>, BlockImportError>, B::Hash)>,
|
||||
);
|
||||
fn justification_imported(
|
||||
&mut self,
|
||||
who: PeerId,
|
||||
hash: &B::Hash,
|
||||
number: NumberFor<B>,
|
||||
success: bool,
|
||||
);
|
||||
fn request_justification(&mut self, hash: &B::Hash, number: NumberFor<B>);
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: BlockT> sc_consensus::JustificationSyncLink<B> for MockChainSyncInterface<B> {
|
||||
fn request_justification(&self, hash: &B::Hash, number: NumberFor<B>) {
|
||||
self.justification_sync_link_request_justification(hash, number);
|
||||
}
|
||||
|
||||
fn clear_justification_requests(&self) {
|
||||
self.justification_sync_link_clear_justification_requests();
|
||||
}
|
||||
}
|
||||
|
||||
mockall::mock! {
|
||||
|
||||
Reference in New Issue
Block a user