Skip to content

Commit

Permalink
Removes unnecessary clones
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Jan 20, 2023
1 parent a6012c2 commit c2b06ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion apps/src/lib/node/ledger/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ where
};

// Tx signature check
let tx_type = match process_tx(tx.clone()) {
let tx_type = match process_tx(tx) {
Ok(ty) => ty,
Err(msg) => {
response.code = ErrorCodes::InvalidSig.into();
Expand Down Expand Up @@ -627,6 +627,8 @@ where
return response;
}

let tx =
Tx::try_from(tx_bytes).expect("Deserialization shouldn't fail");
let wrapper_hash = hash::Hash(tx.unsigned_hash());
let wrapper_hash_key =
replay_protection::get_tx_hash_key(&wrapper_hash);
Expand Down
4 changes: 3 additions & 1 deletion apps/src/lib/node/ledger/shell/process_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ where
// TODO: This should not be hardcoded
let privkey = <EllipticCurve as PairingEngine>::G2Affine::prime_subgroup_generator();

match process_tx(tx.clone()) {
match process_tx(tx) {
// This occurs if the wrapper / protocol tx signature is invalid
Err(err) => TxResult {
code: ErrorCodes::InvalidSig.into(),
Expand Down Expand Up @@ -237,6 +237,8 @@ where
"Couldn't write inner tx hash to write log",
);

let tx = Tx::try_from(tx_bytes)
.expect("Deserialization shouldn't fail");
let wrapper_hash = Hash(tx.unsigned_hash());
let wrapper_hash_key =
replay_protection::get_tx_hash_key(&wrapper_hash);
Expand Down

0 comments on commit c2b06ea

Please sign in to comment.