add post_dispatch (#3229)

* add post_dispatch

* Update traits.rs

* Update checked_extrinsic.rs

* Update traits.rs

* Update traits.rs

* fix build issue

* update runtime version

* fix test build issue
This commit is contained in:
Xiliang Chen
2019-08-08 19:56:04 +12:00
committed by Gavin Wood
parent 3d65753d48
commit 0f0df9850a
6 changed files with 46 additions and 18 deletions
@@ -77,14 +77,16 @@ where
info: DispatchInfo,
len: usize,
) -> Result<DispatchResult, DispatchError> {
let maybe_who = if let Some((id, extra)) = self.signed {
Extra::pre_dispatch(extra, &id, &self.function, info, len)?;
Some(id)
let (maybe_who, pre) = if let Some((id, extra)) = self.signed {
let pre = Extra::pre_dispatch(extra, &id, &self.function, info, len)?;
(Some(id), pre)
} else {
Extra::pre_dispatch_unsigned(&self.function, info, len)?;
None
let pre = Extra::pre_dispatch_unsigned(&self.function, info, len)?;
(None, pre)
};
Ok(self.function.dispatch(Origin::from(maybe_who)))
let res = self.function.dispatch(Origin::from(maybe_who));
Extra::post_dispatch(pre, info, len);
Ok(res)
}
}
@@ -236,6 +236,8 @@ mod tests {
type AccountId = u64;
type Call = ();
type AdditionalSigned = ();
type Pre = ();
fn additional_signed(&self) -> rstd::result::Result<(), &'static str> { Ok(()) }
}