Skip to content

Commit

Permalink
move instead of clone
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex6323 committed Mar 14, 2024
1 parent 9b77ea1 commit 8134473
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions sdk/src/wallet/operations/syncing/outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,29 @@ impl<S: 'static + SecretManage> Wallet<S> {

Ok(outputs_with_meta
.into_iter()
.map(|output_with_meta| {
// check if we know the transaction that created this output and if we created it (if we store incoming
// transactions separated, then this check wouldn't be required)
let remainder = wallet_ledger
.transactions
.get(output_with_meta.metadata().output_id().transaction_id())
.map_or(false, |tx| !tx.incoming);

OutputData {
output_id: output_with_meta.metadata().output_id().to_owned(),
metadata: *output_with_meta.metadata(),
output: output_with_meta.output().clone(),
output_id_proof: output_with_meta.output_id_proof().clone(),
network_id,
remainder,
}
})
.map(
|OutputWithMetadataResponse {
output,
output_id_proof,
metadata,
}| {
// check if we know the transaction that created this output and if we created it (if we store
// incoming transactions separated, then this check wouldn't be required)
let remainder = wallet_ledger
.transactions
.get(metadata.output_id().transaction_id())
.map_or(false, |tx| !tx.incoming);

OutputData {
output_id: metadata.output_id().to_owned(),
metadata,
output,
output_id_proof,
network_id,
remainder,
}
},
)
.collect())
}

Expand Down

0 comments on commit 8134473

Please sign in to comment.