Skip to content

Commit

Permalink
Merge pull request zingolabs#702 from AloeareV/unneded_await
Browse files Browse the repository at this point in the history
Remove unneeded async/await
  • Loading branch information
Oscar-Pepper authored Nov 21, 2023
2 parents efc9b62 + 73f08bd commit f1d3481
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 40 deletions.
24 changes: 10 additions & 14 deletions zingolib/src/blaze/fetch_full_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,20 +421,16 @@ impl TransactionContext {
.iter()
.find(|(nf, _, _, _)| nf == output.nullifier())
{
self.transaction_metadata_set
.write()
.await
.add_new_spent(
transaction.txid(),
transaction_block_height,
true, // this was "unconfirmed" but this fn is invoked inside `if unconfirmed` TODO: add regression test to protect against movement
block_time,
(*nf).into(),
*value,
*transaction_id,
*output_index,
)
.await;
self.transaction_metadata_set.write().await.add_new_spent(
transaction.txid(),
transaction_block_height,
true, // this was "unconfirmed" but this fn is invoked inside `if unconfirmed` TODO: add regression test to protect against movement
block_time,
(*nf).into(),
*value,
*transaction_id,
*output_index,
);
}
}
}
Expand Down
24 changes: 10 additions & 14 deletions zingolib/src/blaze/update_notes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,16 @@ impl UpdateNotes {
.unwrap_or(0);

// Record the future transaction, the one that has spent the nullifiers received in this transaction in the wallet
wallet_transactions
.write()
.await
.add_new_spent(
transaction_id_spent_in,
spent_at_height,
false,
ts,
maybe_spend_nullifier,
value,
transaction_id_spent_from,
output_index,
)
.await;
wallet_transactions.write().await.add_new_spent(
transaction_id_spent_in,
spent_at_height,
false,
ts,
maybe_spend_nullifier,
value,
transaction_id_spent_from,
output_index,
);

// Send the future transaction to be fetched too, in case it has only spent nullifiers and not received any change
if download_memos != MemoDownloadOption::NoMemos {
Expand Down
20 changes: 8 additions & 12 deletions zingolib/src/wallet/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ impl TransactionMetadataSet {

// Records a TxId as having spent some nullifiers from the wallet.
#[allow(clippy::too_many_arguments)]
pub async fn add_new_spent(
pub fn add_new_spent(
&mut self,
txid: TxId,
height: BlockHeight,
Expand All @@ -465,8 +465,8 @@ impl TransactionMetadataSet {
output_index: u32,
) {
match spent_nullifier {
PoolNullifier::Orchard(spent_nullifier) => {
self.add_new_spent_internal::<OrchardDomain>(
PoolNullifier::Orchard(spent_nullifier) => self
.add_new_spent_internal::<OrchardDomain>(
txid,
height,
unconfirmed,
Expand All @@ -475,11 +475,9 @@ impl TransactionMetadataSet {
value,
source_txid,
output_index,
)
.await
}
PoolNullifier::Sapling(spent_nullifier) => {
self.add_new_spent_internal::<SaplingDomain<ChainType>>(
),
PoolNullifier::Sapling(spent_nullifier) => self
.add_new_spent_internal::<SaplingDomain<ChainType>>(
txid,
height,
unconfirmed,
Expand All @@ -488,14 +486,12 @@ impl TransactionMetadataSet {
value,
source_txid,
output_index,
)
.await
}
),
}
}

#[allow(clippy::too_many_arguments)]
async fn add_new_spent_internal<D: DomainWalletExt>(
fn add_new_spent_internal<D: DomainWalletExt>(
&mut self,
txid: TxId,
height: BlockHeight,
Expand Down

0 comments on commit f1d3481

Please sign in to comment.