From b835a0ffbc15dbb71e1bf125a246e39191e36525 Mon Sep 17 00:00:00 2001 From: anorth <445306+anorth@users.noreply.github.com> Date: Thu, 1 Sep 2022 20:59:24 +1200 Subject: [PATCH] review --- actors/multisig/src/lib.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/actors/multisig/src/lib.rs b/actors/multisig/src/lib.rs index 0753052e4..308c2a67b 100644 --- a/actors/multisig/src/lib.rs +++ b/actors/multisig/src/lib.rs @@ -229,10 +229,9 @@ impl Actor { let (_, tx) = ptx .delete(¶ms.id.key()) - .context_code( - ExitCode::USR_ILLEGAL_STATE, - format!("failed to pop transaction {:?} for cancel", params.id), - )? + .with_context_code(ExitCode::USR_ILLEGAL_STATE, || { + format!("failed to pop transaction {:?} for cancel", params.id) + })? .ok_or_else(|| { actor_error!(not_found, "no such transaction {:?} to cancel", params.id) })?; @@ -242,10 +241,10 @@ impl Actor { return Err(actor_error!(forbidden; "Cannot cancel another signers transaction")); } - let calculated_hash = compute_proposal_hash(&tx, rt).context_code( - ExitCode::USR_ILLEGAL_STATE, - format!("failed to compute proposal hash for (tx: {:?})", params.id), - )?; + let calculated_hash = compute_proposal_hash(&tx, rt) + .with_context_code(ExitCode::USR_ILLEGAL_STATE, || { + format!("failed to compute proposal hash for (tx: {:?})", params.id) + })?; if !params.proposal_hash.is_empty() && params.proposal_hash != calculated_hash { return Err(actor_error!(illegal_state, "hash does not match proposal params")); @@ -456,10 +455,10 @@ impl Actor { // update approved on the transaction txn.approved.push(rt.message().caller()); - ptx.set(tx_id.key(), txn.clone()).context_code( - ExitCode::USR_ILLEGAL_STATE, - format!("failed to put transaction {} for approval", tx_id.0), - )?; + ptx.set(tx_id.key(), txn.clone()) + .with_context_code(ExitCode::USR_ILLEGAL_STATE, || { + format!("failed to put transaction {} for approval", tx_id.0) + })?; st.pending_txs = ptx.flush().context_code( ExitCode::USR_ILLEGAL_STATE,