Introduce ChainSyncInterface (#12489)

* Introduce `ChainSyncInterface`

`ChainSyncInterface` provides an asynchronous interface for other
subsystems to submit calls to `ChainSync`. This allows `NetworkService`
to delegate calls to `ChainSync` while still providing the same API
for other subsystems (for now). This makes it possible to move the
syncing code in piecemeal fashion out of `protocol.rs` as the calls
are just forwarded to `ChainSync`.

* Apply review comments

* Fix tests
This commit is contained in:
Aaro Altonen
2022-10-17 10:25:25 +03:00
committed by GitHub
parent 68e2513265
commit ce4cad8b8b
17 changed files with 301 additions and 45 deletions
+2 -1
View File
@@ -864,7 +864,7 @@ where
let block_announce_validator = config
.block_announce_validator
.unwrap_or_else(|| Box::new(DefaultBlockAnnounceValidator));
let chain_sync = ChainSync::new(
let (chain_sync, chain_sync_service) = ChainSync::new(
match network_config.sync_mode {
SyncMode::Full => sc_network_common::sync::SyncMode::Full,
SyncMode::Fast { skip_proofs, storage_chain_mode } =>
@@ -902,6 +902,7 @@ where
fork_id,
import_queue,
chain_sync: Box::new(chain_sync),
chain_sync_service,
metrics_registry: None,
block_announce_config,
block_request_protocol_config,