Skip to content

Commit

Permalink
fix: repalcement txs check inside for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
IMPranshu authored and pinheadmz committed Aug 12, 2022
1 parent 432a30d commit ddc9ac8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/mempool/mempool.js
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,14 @@ class Mempool extends EventEmitter {
conflictingFees += conflict.descFee;
totalEvictions += this.countDescendants(conflict) + 1;

// Replacement TXs must not evict/replace more than 100 descendants
if (totalEvictions > 100) {
throw new VerifyError(tx,
'nonstandard',
'too many potential replacements',
0);
}

if (entry.getDeltaRate() <= conflict.getDeltaRate()) {
throw new VerifyError(tx,
'insufficientfee',
Expand All @@ -991,14 +999,6 @@ class Mempool extends EventEmitter {
}
}

// Replacement TXs must not evict/replace more than 100 descendants
if (totalEvictions > 100) {
throw new VerifyError(tx,
'nonstandard',
'too many potential replacements',
0);
}

// Replacement TX must also pay for the total fees of all descendant
// transactions that will be evicted if an ancestor is replaced.
// Thus the replacement "pays for the bandwidth" of all the conflicts.
Expand Down

0 comments on commit ddc9ac8

Please sign in to comment.