Skip to content
Snippets Groups Projects

Refactor node implementation

Merged Benjamin Gallois requested to merge 216-refactor-node into master
Files
3
+ 26
58
@@ -145,12 +145,14 @@ impl<Api> RuntimeApiCollection for Api where
@@ -145,12 +145,14 @@ impl<Api> RuntimeApiCollection for Api where
/// A client instance.
/// A client instance.
#[derive(Clone)]
#[derive(Clone)]
pub enum Client {
pub enum Client {
#[cfg(feature = "g1")]
Client(
G1(Arc<super::FullClient<g1_runtime::RuntimeApi, super::g1_executor::G1Executor>>),
Arc<
#[cfg(feature = "gtest")]
super::FullClient<
GTest(Arc<super::FullClient<gtest_runtime::RuntimeApi, super::gtest_executor::GTestExecutor>>),
super::runtime_executor::runtime::RuntimeApi,
#[cfg(feature = "gdev")]
super::runtime_executor::Executor,
GDev(Arc<super::FullClient<gdev_runtime::RuntimeApi, super::gdev_executor::GDevExecutor>>),
>,
 
>,
 
),
}
}
macro_rules! with_client {
macro_rules! with_client {
@@ -162,22 +164,8 @@ macro_rules! with_client {
@@ -162,22 +164,8 @@ macro_rules! with_client {
}
}
} => {
} => {
match $self {
match $self {
#[cfg(feature = "g1")]
Self::Client($client) => {
Self::G1($client) => {
#[allow(unused_imports)]
use g1_runtime as runtime;
$( $code )*
}
#[cfg(feature = "gtest")]
Self::GTest($client) => {
#[allow(unused_imports)]
use gtest_runtime as runtime;
$( $code )*
}
#[cfg(feature = "gdev")]
Self::GDev($client) => {
#[allow(unused_imports)]
#[allow(unused_imports)]
use gdev_runtime as runtime;
$( $code )*
$( $code )*
}
}
}
}
@@ -196,52 +184,32 @@ impl ClientHandle for Client {
@@ -196,52 +184,32 @@ impl ClientHandle for Client {
}
}
}
}
#[cfg(feature = "g1")]
impl
impl From<Arc<super::FullClient<g1_runtime::RuntimeApi, super::g1_executor::G1Executor>>>
From<
for Client
Arc<
{
super::FullClient<
fn from(
super::runtime_executor::runtime::RuntimeApi,
client: Arc<super::FullClient<g1_runtime::RuntimeApi, super::g1_executor::G1Executor>>,
super::runtime_executor::Executor,
) -> Self {
>,
Self::G1(client)
}
}
#[cfg(feature = "gtest")]
impl From<Arc<super::FullClient<gtest_runtime::RuntimeApi, super::gtest_executor::GTestExecutor>>>
for Client
{
fn from(
client: Arc<
super::FullClient<gtest_runtime::RuntimeApi, super::gtest_executor::GTestExecutor>,
>,
>,
) -> Self {
> for Client
Self::GTest(client)
}
}
#[cfg(feature = "gdev")]
impl From<Arc<super::FullClient<gdev_runtime::RuntimeApi, super::gdev_executor::GDevExecutor>>>
for Client
{
{
fn from(
fn from(
client: Arc<
client: Arc<
super::FullClient<gdev_runtime::RuntimeApi, super::gdev_executor::GDevExecutor>,
super::FullClient<
 
super::runtime_executor::runtime::RuntimeApi,
 
super::runtime_executor::Executor,
 
>,
>,
>,
) -> Self {
) -> Self {
Self::GDev(client)
Self::Client(client)
}
}
}
}
macro_rules! match_client {
macro_rules! match_client {
($self:ident, $method:ident($($param:ident),*)) => {
($self:ident, $method:ident($($param:ident),*)) => {
match $self {
match $self {
#[cfg(feature = "g1")]
Self::Client(client) => client.$method($($param),*),
Self::G1(client) => client.$method($($param),*),
#[cfg(feature = "gtest")]
Self::GTest(client) => client.$method($($param),*),
#[cfg(feature = "gdev")]
Self::GDev(client) => client.$method($($param),*),
}
}
};
};
}
}
@@ -328,15 +296,15 @@ trait BenchmarkCallSigner<RuntimeCall: Encode + Clone, Signer: Pair> {
@@ -328,15 +296,15 @@ trait BenchmarkCallSigner<RuntimeCall: Encode + Clone, Signer: Pair> {
#[cfg(feature = "g1")]
#[cfg(feature = "g1")]
use g1_runtime as runtime;
use g1_runtime as runtime;
#[cfg(feature = "g1")]
#[cfg(feature = "g1")]
type FullClient = super::FullClient<runtime::RuntimeApi, super::g1_executor::G1Executor>;
type FullClient = super::FullClient<runtime::RuntimeApi, super::runtime_executor::Executor>;
#[cfg(feature = "gdev")]
#[cfg(feature = "gdev")]
use gdev_runtime as runtime;
use gdev_runtime as runtime;
#[cfg(feature = "gdev")]
#[cfg(feature = "gdev")]
type FullClient = super::FullClient<runtime::RuntimeApi, super::gdev_executor::GDevExecutor>;
type FullClient = super::FullClient<runtime::RuntimeApi, super::runtime_executor::Executor>;
#[cfg(feature = "gtest")]
#[cfg(feature = "gtest")]
use gtest_runtime as runtime;
use gtest_runtime as runtime;
#[cfg(feature = "gtest")]
#[cfg(feature = "gtest")]
type FullClient = super::FullClient<runtime::RuntimeApi, super::gtest_executor::GTestExecutor>;
type FullClient = super::FullClient<runtime::RuntimeApi, super::runtime_executor::Executor>;
#[cfg(any(feature = "gdev", feature = "gtest"))]
#[cfg(any(feature = "gdev", feature = "gtest"))]
impl BenchmarkCallSigner<runtime::RuntimeCall, sp_core::sr25519::Pair> for FullClient {
impl BenchmarkCallSigner<runtime::RuntimeCall, sp_core::sr25519::Pair> for FullClient {
Loading