mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 22:21:02 +00:00
Generate dispatch code from macro impl_stubs.
This commit is contained in:
@@ -32,9 +32,6 @@ extern crate polkadot_primitives;
|
|||||||
extern crate polkadot_executor as executor;
|
extern crate polkadot_executor as executor;
|
||||||
extern crate native_runtime;
|
extern crate native_runtime;
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
#[macro_use]
|
|
||||||
extern crate hex_literal;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
@@ -42,14 +39,6 @@ extern crate error_chain;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
||||||
// TODO: move into own crate.
|
|
||||||
#[cfg(test)]
|
|
||||||
macro_rules! map {
|
|
||||||
($( $name:expr => $value:expr ),*) => (
|
|
||||||
vec![ $( ( $name, $value ) ),* ].into_iter().collect()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
|
||||||
/// Parse command line arguments and start the node.
|
/// Parse command line arguments and start the node.
|
||||||
|
|||||||
@@ -39,12 +39,7 @@ impl NativeExecutionDispatch for LocalNativeExecutionDispatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||||
match method {
|
runtime::dispatch(method, data)
|
||||||
"execute_block" => Some(runtime::execute_block(data)),
|
|
||||||
"execute_transaction" => Some(runtime::execute_transaction(data)),
|
|
||||||
"finalise_block" => Some(runtime::finalise_block(data)),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,16 @@ pub fn print<T: Printable + Sized>(value: T) {
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! impl_stubs {
|
macro_rules! impl_stubs {
|
||||||
($( $name:ident ),*) => {}
|
($( $name:ident ),*) => {
|
||||||
|
pub fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||||
|
match method {
|
||||||
|
$(
|
||||||
|
stringify!($name) => Some($name(data)),
|
||||||
|
)*
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
Reference in New Issue
Block a user