Skip to content

Commit

Permalink
Merge commit '9a75a2b3ebbcd1bca66d5496286d14a96247ffa4'
Browse files Browse the repository at this point in the history
  • Loading branch information
techcoderx committed May 20, 2021
2 parents 156ca96 + 9a75a2b commit aaddfaa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/p2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ var p2p = {
if (p2p.recovering) return
var tx = message.d

// if the pool is already full, do nothing at all
if (transaction.isPoolFull())
break

// if its already in the mempool, it means we already handled it
if (transaction.isInPool(tx))
break
Expand Down
12 changes: 9 additions & 3 deletions src/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ transaction = {
pool: [], // the pool holds temporary txs that havent been published on chain yet
eventConfirmation: new EventEmitter(),
addToPool: (txs) => {
if (transaction.pool.length >= max_mempool) {
logr.warn('Mempool is full ('+transaction.pool.length+'/'+max_mempool+' txs), ignoring tx')
if (transaction.isPoolFull())
return
}

for (let y = 0; y < txs.length; y++) {
var exists = false
for (let i = 0; i < transaction.pool.length; i++)
Expand All @@ -26,6 +25,13 @@ transaction = {
}

},
isPoolFull: () => {
if (transaction.pool.length >= max_mempool) {
logr.warn('Mempool is full ('+transaction.pool.length+'/'+max_mempool+' txs), ignoring tx')
return true
}
return false
},
removeFromPool: (txs) => {
for (let y = 0; y < txs.length; y++)
for (let i = 0; i < transaction.pool.length; i++)
Expand Down

0 comments on commit aaddfaa

Please sign in to comment.