Allow using any polkadot client instead of enum Client (#1575)

* WIP

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

* WIP

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

* WIP

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

* WIP

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

* WIP

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

* WIP

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

* WIP

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

* WIP

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

* Apply suggestions from code review

* WIP

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

* WIP

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

* WIP

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

* CLEANUP

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

* link in doc

* doc
This commit is contained in:
Cecile Tonglet
2020-08-13 10:40:39 +02:00
committed by GitHub
parent 7914847950
commit 661c10a206
7 changed files with 89 additions and 31 deletions
@@ -9,8 +9,11 @@ adder = { package = "test-parachain-adder", path = ".." }
parachain = { package = "polkadot-parachain", path = "../../.." }
collator = { package = "polkadot-collator", path = "../../../../collator" }
primitives = { package = "polkadot-primitives", path = "../../../../primitives" }
service = { package = "polkadot-service", path = "../../../../service" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
client-api = { package = "sc-client-api", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
parking_lot = "0.10.0"
codec = { package = "parity-scale-codec", version = "1.3.4" }
futures = "0.3.4"
@@ -20,15 +20,17 @@ use std::collections::HashMap;
use std::sync::Arc;
use adder::{HeadData as AdderHead, BlockData as AdderBody};
use sp_core::Pair;
use sp_core::{traits::SpawnNamed, Pair};
use codec::{Encode, Decode};
use primitives::v0::{
Hash, DownwardMessage,
Block, Hash, DownwardMessage,
HeadData, BlockData, Id as ParaId, LocalValidationData, GlobalValidationData,
};
use collator::{ParachainContext, Network, BuildParachainContext, Cli, SubstrateCli};
use parking_lot::Mutex;
use futures::future::{Ready, ready, FutureExt};
use sp_runtime::traits::BlakeTwo256;
use client_api::Backend as BackendT;
const GENESIS: AdderHead = AdderHead {
number: 0,
@@ -103,12 +105,19 @@ impl ParachainContext for AdderContext {
impl BuildParachainContext for AdderContext {
type ParachainContext = Self;
fn build<SP>(
fn build<SP, Client, Backend>(
self,
_: collator::Client,
_: Arc<Client>,
_: SP,
network: impl Network + Clone + 'static,
) -> Result<Self::ParachainContext, ()> {
) -> Result<Self::ParachainContext, ()>
where
SP: SpawnNamed + Clone + Send + Sync + 'static,
Backend: BackendT<Block>,
Backend::State: sp_api::StateBackend<BlakeTwo256>,
Client: service::AbstractClient<Block, Backend> + 'static,
Client::Api: service::RuntimeApiCollection<StateBackend = Backend::State>,
{
Ok(Self { _network: Some(Arc::new(network)), ..self })
}
}