Commit bb44855a authored by Cecile Tonglet's avatar Cecile Tonglet Committed by Cecile Tonglet
Browse files

Add SyncOracle to network's Service (#1543)

* WIP

* WIP

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

* WIP

Forked at: e9164236
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
parent beb7a096
......@@ -4532,6 +4532,7 @@ dependencies = [
"sc-network-gossip",
"sp-api",
"sp-blockchain",
"sp-consensus",
"sp-core",
"sp-keyring",
"sp-runtime",
......
......@@ -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))
......
......@@ -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 = "rococo-branch" }
sc-network-gossip = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
futures = "0.3.5"
......
......@@ -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 {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment