Commit 96cdf519 authored by Cecile Tonglet's avatar Cecile Tonglet
Browse files

CLEANUP

Forked at: e9164236
Parent branch: origin/rococo-branch
parent b66861cb
Pipeline #103767 canceled with stages
in 5 minutes and 50 seconds
......@@ -67,7 +67,7 @@ pub use sc_network::PeerId;
pub use service::{RuntimeApiCollection, Client};
pub use sc_cli::SubstrateCli;
#[cfg(not(feature = "service-rewr"))]
use polkadot_service::{FullNodeHandles, AbstractClient, YaExecuteWithClient};
use polkadot_service::{FullNodeHandles, AbstractClient, ClientHandle};
#[cfg(feature = "service-rewr")]
use polkadot_service_new::{
self as polkadot_service,
......@@ -200,12 +200,12 @@ pub async fn collate<P>(
Some(collation)
}
/// Build a collator service based on the `YaExecuteWithClient`.
/// Build a collator service based on the `ClientHandle`.
#[cfg(feature = "service-rewr")]
pub fn build_collator_service<P>(
spawner: SpawnTaskHandle,
handles: FullNodeHandles,
client: impl YaExecuteWithClient,
client: impl ClientHandle,
para_id: ParaId,
key: Arc<CollatorPair>,
build_parachain_context: P,
......@@ -352,12 +352,12 @@ impl<P> polkadot_service::ExecuteWithClient for BuildCollationWork<P>
}
}
/// Build a collator service based on the `YaExecuteWithClient`.
/// Build a collator service based on the `ClientHandle`.
#[cfg(not(feature = "service-rewr"))]
pub fn build_collator_service<P>(
spawner: SpawnTaskHandle,
handles: FullNodeHandles,
client: impl YaExecuteWithClient,
client: impl ClientHandle,
para_id: ParaId,
key: Arc<CollatorPair>,
build_parachain_context: P,
......
......@@ -26,7 +26,7 @@ use polkadot_primitives::v0::{
Block, Hash, CollatorId, Id as ParaId,
};
use polkadot_runtime_common::{parachains, registrar, BlockHashCount};
use polkadot_service::{new_full, FullNodeHandles, AbstractClient, YaExecuteWithClient, ExecuteWithClient};
use polkadot_service::{new_full, FullNodeHandles, AbstractClient, ClientHandle, ExecuteWithClient};
use polkadot_test_runtime::{RestrictFunctionality, Runtime, SignedExtra, SignedPayload, VERSION};
use sc_chain_spec::ChainSpec;
use sc_client_api::{execution_extensions::ExecutionStrategies, BlockchainEvents};
......@@ -88,10 +88,10 @@ pub fn polkadot_test_new_full(
Ok((task_manager, client, handles, network, rpc_handlers))
}
/// A wrapper for the test client that implements `YaExecuteWithClient`.
/// A wrapper for the test client that implements `ClientHandle`.
pub struct TestClient(pub Arc<polkadot_service::FullClient<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutor>>);
impl YaExecuteWithClient for TestClient {
impl ClientHandle for TestClient {
fn execute_with<T: ExecuteWithClient>(&self, t: T) -> T::Output {
T::execute_with_client::<_, _, polkadot_service::FullBackend>(t, self.0.clone())
}
......
......@@ -118,8 +118,15 @@ pub trait ExecuteWithClient {
Client: AbstractClient<Block, Backend, Api = Api> + 'static;
}
/// Yet Another ExecuteWithClient
pub trait YaExecuteWithClient {
/// A handle to a Polkadot client instance.
///
/// The Polkadot service supports multiple different runtimes (Westend, Polkadot itself, etc). As each runtime has a
/// specialized client, we need to hide them behind a trait. This is this trait.
///
/// When wanting to work with the inner client, you need to use `ClientHandle::execute_with`.
///
/// See `ExecuteWithClient` for more information.
pub trait ClientHandle {
/// Execute the given something with the client.
fn execute_with<T: ExecuteWithClient>(&self, t: T) -> T::Output;
}
......@@ -135,7 +142,7 @@ pub enum Client {
Rococo(Arc<crate::FullClient<rococo_runtime::RuntimeApi, crate::RococoExecutor>>),
}
impl YaExecuteWithClient for Client {
impl ClientHandle for Client {
fn execute_with<T: ExecuteWithClient>(&self, t: T) -> T::Output {
match self {
Self::Polkadot(client) => {
......
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