Commit 5527eaaf authored by Cecile Tonglet's avatar Cecile Tonglet
Browse files

WIP

Forked at: e9164236
Parent branch: origin/rococo-branch
parent ac4e6c4c
......@@ -121,7 +121,7 @@ pub trait BuildParachainContext {
/// Build the `ParachainContext`.
fn build<SP, Client, Block, Backend>(
self,
client: Client,
client: Arc<Client>,
spawner: SP,
network: impl Network + SyncOracle + Clone + 'static,
) -> Result<Self::ParachainContext, ()>
......@@ -225,7 +225,6 @@ struct BuildCollationWork<P> {
key: Arc<CollatorPair>,
build_parachain_context: P,
spawner: SpawnTaskHandle,
client: polkadot_service::Client,
}
impl<P> polkadot_service::ExecuteWithClient for BuildCollationWork<P>
......@@ -242,15 +241,6 @@ impl<P> polkadot_service::ExecuteWithClient for BuildCollationWork<P>
Backend::State: sp_api::StateBackend<BlakeTwo256>,
Api: RuntimeApiCollection<StateBackend = Backend::State>,
Client: AbstractClient<Block, Backend, Api = Api> + 'static,
/*
Client: BlockchainEvents<Block> + sp_api::ProvideRuntimeApi<Block> + HeaderBackend<Block>
+ Sized + Send + Sync
+ sp_api::CallApiAt<
Block,
Error = sp_blockchain::Error,
StateBackend = Backend::State
>,
*/
{
let polkadot_network = self.handles
.polkadot_network
......@@ -263,7 +253,7 @@ impl<P> polkadot_service::ExecuteWithClient for BuildCollationWork<P>
.ok_or_else(|| "Collator cannot run when validation networking has not been started")?;
let parachain_context = match self.build_parachain_context.build(
self.client,
client.clone(),
self.spawner.clone(),
polkadot_network.clone(),
) {
......@@ -383,7 +373,6 @@ fn build_collator_service<P>(
key,
build_parachain_context,
spawner,
client: client.clone(),
})
}
......
......@@ -120,6 +120,11 @@ pub trait ExecuteWithClient {
Client: AbstractClient<Block, Backend, Api = Api> + 'static;
}
/// Yet Another ExecuteWithClient
pub trait YaExecuteWithClient {
fn execute_with<T: ExecuteWithClient>(&self, t: T) -> T::Output;
}
/// A client instance of Polkadot.
///
/// See [`ExecuteWithClient`] for more information.
......@@ -129,12 +134,11 @@ pub enum Client {
Westend(Arc<crate::FullClient<westend_runtime::RuntimeApi, crate::WestendExecutor>>),
Kusama(Arc<crate::FullClient<kusama_runtime::RuntimeApi, crate::KusamaExecutor>>),
Rococo(Arc<crate::FullClient<rococo_runtime::RuntimeApi, crate::RococoExecutor>>),
//Test(Arc<crate::FullClient<polkadot_test_runtime::RuntimeApi, polkadot_test_service::RococoExecutor>>),
}
impl Client {
impl YaExecuteWithClient for Client {
/// Execute the given something with the client.
pub fn execute_with<T: ExecuteWithClient>(&self, t: T) -> T::Output {
fn execute_with<T: ExecuteWithClient>(&self, t: T) -> T::Output {
match self {
Self::Polkadot(client) => {
T::execute_with_client::<_, _, crate::FullBackend>(t, client.clone())
......
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