From 8c1b79c7e8365878df305bd838b2082d051e33ba Mon Sep 17 00:00:00 2001 From: Gav Date: Thu, 8 Feb 2018 00:02:31 +0100 Subject: [PATCH] Docs --- substrate/executor/src/native_executor.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/substrate/executor/src/native_executor.rs b/substrate/executor/src/native_executor.rs index eef18be128..109702b577 100644 --- a/substrate/executor/src/native_executor.rs +++ b/substrate/executor/src/native_executor.rs @@ -21,11 +21,18 @@ use wasm_executor::WasmExecutor; use std::panic::catch_unwind; +/// Delegate for dispatching a CodeExecutor call to native code. pub trait NativeExecutionDispatch { + /// Get the wasm code that the native dispatch will be equivalent to. fn native_equivalent() -> &'static [u8]; + + /// Dispatch a method and input data to be executed natively. Returns `Some` result or `None` + /// if the `method` is unknown. Panics if there's an unrecoverable error. fn dispatch(method: &str, data: &[u8]) -> Option>; } +/// A generic `CodeExecutor` implementation that uses a delegate to determine wasm code equivalence +/// and dispatch to native code when possible, falling back on `WasmExecutor` when not. pub struct NativeExecutor { pub _dummy: ::std::marker::PhantomData, }