Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CLEANUP
Forked at: e916423
Parent branch: origin/rococo-branch
  • Loading branch information
cecton committed Aug 13, 2020
commit 96cdf519c389141f77c973aa2f0e3cfc1e398814
10 changes: 5 additions & 5 deletions collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions node/test-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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())
}
Expand Down
13 changes: 10 additions & 3 deletions service/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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) => {
Expand Down