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 e7051c4 commit 721162b
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 @@ -602,7 +602,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 @@ -632,6 +632,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 @@ -117,7 +117,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 @@ -241,6 +241,8 @@ where
// Write inner hash to WAL
temp_wl_storage.write_log.write(&inner_hash_key, vec![]).expect("Couldn't write inner tranasction hash to temporary 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 721162b

Please sign in to comment.