make polkadot-runtime optional feature (#3820)

* make polkadot-runtime optional feature

* sprinkle some cfg statements

* ok

* ok, ok

* add CI check

* set -e

* chmod +x

* fixes

* fmt

* nicer compile errors

* Update outdated comments
This commit is contained in:
Andronik Ordian
2021-09-13 12:28:33 +02:00
committed by GitHub
parent 3d2c4db477
commit 33d7f9dd7b
10 changed files with 152 additions and 52 deletions
+12
View File
@@ -40,9 +40,19 @@ pub type FullBackend = sc_service::TFullBackend<Block>;
pub type FullClient<RuntimeApi, ExecutorDispatch> =
sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;
#[cfg(not(any(
feature = "rococo",
feature = "kusama",
feature = "westend",
feature = "polkadot"
)))]
compile_error!("at least one runtime feature must be enabled");
/// The native executor instance for Polkadot.
#[cfg(feature = "polkadot")]
pub struct PolkadotExecutorDispatch;
#[cfg(feature = "polkadot")]
impl sc_executor::NativeExecutionDispatch for PolkadotExecutorDispatch {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
@@ -233,6 +243,7 @@ macro_rules! with_client {
}
} => {
match $self {
#[cfg(feature = "polkadot")]
Self::Polkadot($client) => { $( $code )* },
#[cfg(feature = "westend")]
Self::Westend($client) => { $( $code )* },
@@ -249,6 +260,7 @@ macro_rules! with_client {
/// See [`ExecuteWithClient`] for more information.
#[derive(Clone)]
pub enum Client {
#[cfg(feature = "polkadot")]
Polkadot(Arc<FullClient<polkadot_runtime::RuntimeApi, PolkadotExecutorDispatch>>),
#[cfg(feature = "westend")]
Westend(Arc<FullClient<westend_runtime::RuntimeApi, WestendExecutorDispatch>>),