Add SyncOracle to network's Service (#1543)

* WIP

* WIP

Forked at: e91642361133dba084a9c9b3efa45fcb6cd3c5ca
Parent branch: origin/rococo-branch

* WIP

Forked at: e91642361133dba084a9c9b3efa45fcb6cd3c5ca
Parent branch: origin/rococo-branch

* Apply suggestions from code review

* Update collator/src/lib.rs

* Update collator/src/lib.rs

* Update network/src/protocol/mod.rs
This commit is contained in:
Cecile Tonglet
2020-08-06 10:15:21 +02:00
committed by GitHub
parent 497772da18
commit e818944cbe
4 changed files with 17 additions and 4 deletions
+1
View File
@@ -4532,6 +4532,7 @@ dependencies = [
"sc-network-gossip",
"sp-api",
"sp-blockchain",
"sp-consensus",
"sp-core",
"sp-keyring",
"sp-runtime",
+5 -4
View File
@@ -76,6 +76,7 @@ use polkadot_service_new::{
use sc_service::SpawnTaskHandle;
use sp_core::traits::SpawnNamed;
use sp_runtime::traits::BlakeTwo256;
use consensus_common::SyncOracle;
const COLLATION_TIMEOUT: Duration = Duration::from_secs(30);
@@ -120,7 +121,7 @@ pub trait BuildParachainContext {
self,
client: polkadot_service::Client,
spawner: SP,
network: impl Network + Clone + 'static,
network: impl Network + SyncOracle + Clone + 'static,
) -> Result<Self::ParachainContext, ()>
where
SP: SpawnNamed + Clone + Send + Sync + 'static;
@@ -391,7 +392,7 @@ where
.into());
}
let (task_manager, client, handlers) = polkadot_service::build_full(
let (task_manager, client, handles) = polkadot_service::build_full(
config,
Some((key.public(), para_id)),
None,
@@ -402,11 +403,11 @@ where
let future = build_collator_service(
task_manager.spawn_handle(),
handlers,
handles,
client,
para_id,
key,
build_parachain_context
build_parachain_context,
)?;
Ok((future, task_manager))
+1
View File
@@ -17,6 +17,7 @@ polkadot-erasure-coding = { path = "../erasure-coding" }
codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive"] }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network-gossip = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
futures = "0.3.5"
+10
View File
@@ -1488,6 +1488,16 @@ impl<N> av_store::ErasureNetworking for Service<N> {
}
}
impl<N> sp_consensus::SyncOracle for Service<N> where for<'r> &'r N: sp_consensus::SyncOracle {
fn is_major_syncing(&mut self) -> bool {
self.network_service.is_major_syncing()
}
fn is_offline(&mut self) -> bool {
self.network_service.is_offline()
}
}
/// Errors when interacting with the statement router.
#[derive(Debug, derive_more::Display, derive_more::From)]
pub enum RouterError {