diff --git a/substrate/core/cli/src/execution_strategy.rs b/substrate/core/cli/src/execution_strategy.rs new file mode 100644 index 0000000000..bd3030906e --- /dev/null +++ b/substrate/core/cli/src/execution_strategy.rs @@ -0,0 +1,35 @@ +// Copyright 2018-2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +#![allow(missing_docs)] + +use structopt::clap::{arg_enum, _clap_count_exprs}; + +arg_enum! { + /// How to execute blocks + #[derive(Debug, Clone, Copy)] + pub enum ExecutionStrategy { + // Execute with native build (if available, WebAssembly otherwise). + Native, + // Only execute with the WebAssembly build. + Wasm, + // Execute with both native (where available) and WebAssembly builds. + Both, + // Execute with the native build if possible; if it fails, then execute with WebAssembly. + NativeElseWasm, + } +} + diff --git a/substrate/core/cli/src/lib.rs b/substrate/core/cli/src/lib.rs index be1db4f931..7dc9519fa8 100644 --- a/substrate/core/cli/src/lib.rs +++ b/substrate/core/cli/src/lib.rs @@ -22,6 +22,7 @@ #[macro_use] mod traits; mod params; +mod execution_strategy; pub mod error; pub mod informant; diff --git a/substrate/core/cli/src/params.rs b/substrate/core/cli/src/params.rs index 702416aa0c..e3fa04c936 100644 --- a/substrate/core/cli/src/params.rs +++ b/substrate/core/cli/src/params.rs @@ -20,6 +20,8 @@ use std::path::PathBuf; use structopt::{StructOpt, clap::{arg_enum, _clap_count_exprs, App, AppSettings, SubCommand, Arg}}; use client; +pub use crate::execution_strategy::ExecutionStrategy; + /// Auxiliary macro to implement `GetLogFilter` for all types that have the `shared_params` field. macro_rules! impl_get_log_filter { ( $type:ident ) => { @@ -31,22 +33,6 @@ macro_rules! impl_get_log_filter { } } -arg_enum! { - /// How to execute blocks - #[allow(missing_docs)] - #[derive(Debug, Clone, Copy)] - pub enum ExecutionStrategy { - // Execute with native build (if available, WebAssembly otherwise). - Native, - // Only execute with the WebAssembly build. - Wasm, - // Execute with both native (where available) and WebAssembly builds. - Both, - // Execute with the native build if possible; if it fails, then execute with WebAssembly. - NativeElseWasm, - } -} - impl Into for ExecutionStrategy { fn into(self) -> client::ExecutionStrategy { match self { diff --git a/substrate/core/client/src/genesis.rs b/substrate/core/client/src/genesis.rs index f02be3116a..3ac93f4f57 100644 --- a/substrate/core/client/src/genesis.rs +++ b/substrate/core/client/src/genesis.rs @@ -39,7 +39,6 @@ pub fn construct_genesis_block< #[cfg(test)] mod tests { - use super::*; use codec::{Encode, Decode, Joiner}; use executor::native_executor_instance; use state_machine::{self, OverlayedChanges, ExecutionStrategy, InMemoryChangesTrieStorage}; @@ -49,7 +48,6 @@ mod tests { runtime::{Hash, Transfer, Block, BlockNumber, Header, Digest}, AccountKeyring, Sr25519Keyring, }; - use sr_primitives::traits::BlakeTwo256; use primitives::Blake2Hasher; use hex::*;