Network sync refactoring (part 5) (#11825)

* Make `chain_sync` an explicit networking parameter instead of offering factory method

* Derive `Copy` on `SyncMode` and remove cloning
This commit is contained in:
Nazar Mokrynskyi
2022-07-29 23:17:49 +03:00
committed by GitHub
parent 3a4ad68d09
commit 56f16f5500
5 changed files with 69 additions and 84 deletions
+5 -11
View File
@@ -96,14 +96,8 @@ where
/// valid.
pub import_queue: Box<dyn ImportQueue<B>>,
/// Factory function that creates a new instance of chain sync.
pub create_chain_sync: Box<
dyn FnOnce(
sc_network_common::sync::SyncMode,
Arc<Client>,
Option<Arc<dyn WarpSyncProvider<B>>>,
) -> crate::error::Result<Box<dyn ChainSync<B>>>,
>,
/// Instance of chain sync implementation.
pub chain_sync: Box<dyn ChainSync<B>>,
/// Registry for recording prometheus metrics to.
pub metrics_registry: Option<Registry>,
@@ -138,8 +132,8 @@ where
/// both outgoing and incoming requests.
pub state_request_protocol_config: RequestResponseConfig,
/// Optional warp sync protocol support. Include protocol config and sync provider.
pub warp_sync: Option<(Arc<dyn WarpSyncProvider<B>>, RequestResponseConfig)>,
/// Optional warp sync protocol config.
pub warp_sync_protocol_config: Option<RequestResponseConfig>,
}
/// Role of the local node.
@@ -352,7 +346,7 @@ impl From<multiaddr::Error> for ParseErr {
}
/// Sync operation mode.
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum SyncMode {
/// Full block download and verification.
Full,