From eb9bfb43705c2ab94088bb21b5bbf0c257720034 Mon Sep 17 00:00:00 2001 From: dwn1998 <42262393+dwn1998@users.noreply.github.com> Date: Wed, 6 Sep 2023 15:47:10 -0400 Subject: [PATCH] Update legacypool.go --- core/txpool/legacypool/legacypool.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index 00e326c4b8..c29baf18fc 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -883,6 +883,16 @@ func (pool *LegacyPool) promoteTx(addr common.Address, hash common.Hash, tx *typ pendingDiscardMeter.Mark(1) return false } + + //Check balance for Overdraft + balance := pool.currentState.GetBalance(addr) + if list.totalcost.Cmp(balance) > 0 { + pool.all.Remove(hash) + pool.priced.Removed(1) + pendingDiscardMeter.Mark(1) + return false + } + // Otherwise discard any previous transaction and mark this if old != nil { pool.all.Remove(old.Hash()) @@ -892,6 +902,7 @@ func (pool *LegacyPool) promoteTx(addr common.Address, hash common.Hash, tx *typ // Nothing was replaced, bump the pending counter pendingGauge.Inc(1) } + // Set the potentially new pending nonce and notify any subsystems of the new tx pool.pendingNonces.set(addr, tx.Nonce()+1)