diff --git a/collator/src/lib.rs b/collator/src/lib.rs index d898a86fbc95..10ba819f5d76 100644 --- a/collator/src/lib.rs +++ b/collator/src/lib.rs @@ -79,7 +79,7 @@ pub use substrate_network::PeerId; const COLLATION_TIMEOUT: Duration = Duration::from_secs(30); /// An abstraction over the `Network` with useful functions for a `Collator`. -pub trait Network { +pub trait Network: Send + Sync { /// Convert the given `CollatorId` to a `PeerId`. fn collator_id_to_peer_id(&self, collator_id: CollatorId) -> Box, Error=()> + Send>; @@ -93,8 +93,8 @@ pub trait Network { } impl Network for ValidationNetwork where - P: 'static, - E: 'static, + P: 'static + Send + Sync, + E: 'static + Send + Sync, { fn collator_id_to_peer_id(&self, collator_id: CollatorId) -> Box, Error=()> + Send> @@ -438,7 +438,7 @@ pub fn run_collator( P: BuildParachainContext + Send + 'static, P::ParachainContext: Send + 'static, <::ProduceCandidate as IntoFuture>::Future: Send + 'static, - E: IntoFuture, + E: IntoFuture, E::Future: Send + Clone + Sync + 'static, I: IntoIterator, ArgT: Into + Clone, diff --git a/test-parachains/adder/collator/src/main.rs b/test-parachains/adder/collator/src/main.rs index ac86bc00e999..c57f488e1b99 100644 --- a/test-parachains/adder/collator/src/main.rs +++ b/test-parachains/adder/collator/src/main.rs @@ -47,6 +47,8 @@ const GENESIS_BODY: AdderBody = AdderBody { #[derive(Clone)] struct AdderContext { db: Arc>>, + /// We store it here to make sure that our interfaces require the correct bounds. + _network: Option>, } /// The parachain context. @@ -99,8 +101,8 @@ impl ParachainContext for AdderContext { impl BuildParachainContext for AdderContext { type ParachainContext = Self; - fn build(self, _: Arc) -> Result { - Ok(self) + fn build(self, network: Arc) -> Result { + Ok(Self { _network: Some(network), ..self }) } } @@ -133,6 +135,7 @@ fn main() { let context = AdderContext { db: Arc::new(Mutex::new(HashMap::new())), + _network: None, }; let res = ::collator::run_collator(