From ddc9ac8cf71c1dba01e54c7331097e0593522598 Mon Sep 17 00:00:00 2001 From: Pranshu Agrawal Date: Fri, 12 Aug 2022 00:41:53 +0530 Subject: [PATCH] fix: repalcement txs check inside for loop --- lib/mempool/mempool.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/mempool/mempool.js b/lib/mempool/mempool.js index da5b2f492..095a32ad3 100644 --- a/lib/mempool/mempool.js +++ b/lib/mempool/mempool.js @@ -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', @@ -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.