Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
change(executor): cancel will not revert current execution unit changes
Browse files Browse the repository at this point in the history
We can still use panic to revert changes
  • Loading branch information
zeroqn committed Jun 11, 2020
1 parent b04cfad commit 548d621
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions framework/src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ impl<DB: TrieDB> CommitHooks<DB> {
match panic::catch_unwind(AssertUnwindSafe(hook)) {
Ok(_) if !context.canceled() => states.stash(),
Ok(_) => {
states.stash()?;

// An reason must be passed to cancel
let reason = context.cancel_reason();
debug_assert!(reason.is_some());

states.revert_cache()?;

Err(ExecutorError::Canceled {
service: context.get_service_name().to_owned(),
reason,
Expand Down
2 changes: 1 addition & 1 deletion framework/src/executor/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ fn test_tx_hook_before_cancel() {
let caller = Address::from_hex("0xf8389d774afdad8755ef8e629e5a154fddc6325a").unwrap();

let before = read!(executor, &params, &caller, r#""before""#);
assert_eq!(before.succeed_data, r#""""#);
assert_eq!(before.succeed_data, r#""before""#);

let tx_hook_before_cancel = read!(executor, &params, &caller, r#""tx_hook_before_cancel""#);
assert_eq!(tx_hook_before_cancel.succeed_data, r#""""#);
Expand Down

0 comments on commit 548d621

Please sign in to comment.