Macro sc_executor::native_executor_instance
source · [−]macro_rules! native_executor_instance {
( $pub:vis $name:ident, $dispatcher:path, $version:path $(,)?) => { ... };
( $pub:vis $name:ident, $dispatcher:path, $version:path, $custom_host_functions:ty $(,)?) => { ... };
(IMPL $name:ident, $dispatcher:path, $version:path, $custom_host_functions:ty) => { ... };
}
Expand description
Implements a NativeExecutionDispatch
for provided parameters.
Example
sc_executor::native_executor_instance!(
pub MyExecutor,
substrate_test_runtime::api::dispatch,
substrate_test_runtime::native_version,
);
With custom host functions
When you want to use custom runtime interfaces from within your runtime, you need to make the executor aware of the host functions for these interfaces.
#[runtime_interface]
trait MyInterface {
fn say_hello_world(data: &str) {
println!("Hello world from: {}", data);
}
}
sc_executor::native_executor_instance!(
pub MyExecutor,
substrate_test_runtime::api::dispatch,
substrate_test_runtime::native_version,
my_interface::HostFunctions,
);
When you have multiple interfaces, you can give the host functions as a tuple e.g.:
(my_interface::HostFunctions, my_interface2::HostFunctions)