Unverified Commit 16f646dc authored by thiolliere's avatar thiolliere Committed by GitHub
Browse files

Minor refactor (#3386)



* minro refactor

* Update node/core/runtime-api/src/lib.rs
Co-authored-by: Keith Yeung's avatarKeith Yeung <kungfukeith11@gmail.com>

* Update node/core/runtime-api/src/lib.rs
Co-authored-by: default avatarBastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Keith Yeung's avatarKeith Yeung <kungfukeith11@gmail.com>
Co-authored-by: default avatarBastian Köcher <bkchr@users.noreply.github.com>
parent 010ea972
Pipeline #144969 passed with stages
in 38 minutes and 34 seconds
......@@ -302,33 +302,15 @@ where
let _timer = metrics.time_make_runtime_api_request();
macro_rules! query {
($req_variant:ident, $api_name:ident (), $sender:expr) => {{
($req_variant:ident, $api_name:ident ($($param:expr),*), $sender:expr) => {{
let sender = $sender;
let api = client.runtime_api();
let res = api.$api_name(&BlockId::Hash(relay_parent))
let res = api.$api_name(&BlockId::Hash(relay_parent) $(, $param.clone() )*)
.map_err(|e| RuntimeApiError::from(format!("{:?}", e)));
metrics.on_request(res.is_ok());
let _ = sender.send(res.clone());
if let Ok(res) = res {
Some(RequestResult::$req_variant(relay_parent, res.clone()))
} else {
None
}
}};
($req_variant:ident, $api_name:ident ($($param:expr),+), $sender:expr) => {{
let sender = $sender;
let api = client.runtime_api();
let res = api.$api_name(&BlockId::Hash(relay_parent), $($param.clone()),*)
.map_err(|e| RuntimeApiError::from(format!("{:?}", e)));
metrics.on_request(res.is_ok());
let _ = sender.send(res.clone());
if let Ok(res) = res {
Some(RequestResult::$req_variant(relay_parent, $($param),+, res.clone()))
} else {
None
}
res.ok().map(|res| RequestResult::$req_variant(relay_parent, $( $param, )* res))
}}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment