-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathexecutor.rs
More file actions
50 lines (36 loc) · 1.53 KB
/
Copy pathexecutor.rs
File metadata and controls
50 lines (36 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! This module declares an `AlephExecutor` which is either a
//! * `WasmExecutor`, for production and test build (when no local debugging is required)
//! * `NativeElseWasmExecutor` for `runtime-benchmarks` and local debugging builds
use sc_service::Configuration;
#[cfg(not(feature = "runtime-benchmarks"))]
pub mod aleph_executor {
use sc_executor::WasmExecutor;
use super::Configuration;
type ExtendHostFunctions = (sp_io::SubstrateHostFunctions,);
pub type Executor = WasmExecutor<ExtendHostFunctions>;
pub fn get_executor(config: &Configuration) -> Executor {
sc_service::new_wasm_executor(config)
}
}
#[cfg(feature = "runtime-benchmarks")]
pub mod aleph_executor {
use sc_executor::NativeElseWasmExecutor;
use super::Configuration;
pub struct ExecutorDispatch;
impl sc_executor::NativeExecutionDispatch for ExecutorDispatch {
#[cfg(feature = "runtime-benchmarks")]
type ExtendHostFunctions = (frame_benchmarking::benchmarking::HostFunctions,);
#[cfg(not(feature = "runtime-benchmarks"))]
type ExtendHostFunctions = ();
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
aleph_runtime::api::dispatch(method, data)
}
fn native_version() -> sc_executor::NativeVersion {
aleph_runtime::native_version()
}
}
pub type Executor = NativeElseWasmExecutor<ExecutorDispatch>;
pub fn get_executor(config: &Configuration) -> Executor {
sc_service::new_native_or_wasm_executor(config)
}
}