mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
Fast check for duplicate tx in the pool (#1392)
This commit is contained in:
parent
7ca4d45bf5
commit
8c820a8929
2 changed files with 8 additions and 0 deletions
|
@ -179,6 +179,12 @@ where
|
|||
|
||||
// Combine all the txs from the pool with any extra txs provided.
|
||||
let mut txs = self.all_transactions();
|
||||
|
||||
// Quick check to see if we have seen this tx before.
|
||||
if txs.contains(&entry.tx) {
|
||||
return Err(PoolError::DuplicateTx);
|
||||
}
|
||||
|
||||
txs.extend(extra_txs);
|
||||
|
||||
let agg_tx = if txs.is_empty() {
|
||||
|
|
|
@ -174,6 +174,8 @@ pub enum PoolError {
|
|||
LowFeeTransaction(u64),
|
||||
/// Attempt to add a duplicate output to the pool.
|
||||
DuplicateCommitment,
|
||||
/// Attempt to add a duplicate tx to the pool.
|
||||
DuplicateTx,
|
||||
/// Other kinds of error (not yet pulled out into meaningful errors).
|
||||
Other(String),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue