Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Maxim <59533214+biryukovmaxim@users.noreply.github.com>
  • Loading branch information
michaelsutton and biryukovmaxim committed Sep 1, 2024
1 parent 8e279c3 commit 4459b11
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions mining/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,15 +738,7 @@ impl MiningManager {
.entries
.iter()
.zip(transaction.tx.inputs.iter())
.filter_map(
|(entry, input)| {
if entry.is_none() {
Some(input.previous_outpoint.transaction_id)
} else {
None
}
},
)
.filter_map(|(entry, input)| entry.is_none().then_some(input.previous_outpoint.transaction_id))
.collect::<Vec<_>>();

// A transaction may have missing outpoints for legitimate reasons related to concurrency, like a race condition between
Expand All @@ -762,15 +754,14 @@ impl MiningManager {
};

// This call cleanly removes the invalid transaction.
let result = mempool.remove_transaction(
&transaction_id,
false,
TxRemovalReason::RevalidationWithMissingOutpoints,
extra_info.as_str(),
);
if let Err(err) = result {
warn!("Failed to remove transaction {} from mempool: {}", transaction_id, err);
}
_ = mempool
.remove_transaction(
&transaction_id,
false,
TxRemovalReason::RevalidationWithMissingOutpoints,
extra_info.as_str(),
)
.inspect_err(|err| warn!("Failed to remove transaction {} from mempool: {}", transaction_id, err));
missing_outpoint += 1;
}
Err(err) => {
Expand All @@ -782,10 +773,9 @@ impl MiningManager {
transaction_id, err
);
// This call cleanly removes the invalid transaction and its redeemers.
let result = mempool.remove_transaction(&transaction_id, true, TxRemovalReason::Muted, "");
if let Err(err) = result {
warn!("Failed to remove transaction {} from mempool: {}", transaction_id, err);
}
_ = mempool
.remove_transaction(&transaction_id, true, TxRemovalReason::Muted, "")
.inspect_err(|err| warn!("Failed to remove transaction {} from mempool: {}", transaction_id, err));
invalid += 1;
}
}
Expand Down

0 comments on commit 4459b11

Please sign in to comment.