diff --git a/core/tx_list.go b/core/tx_list.go index ba7951100..d3b1fb563 100644 --- a/core/tx_list.go +++ b/core/tx_list.go @@ -240,6 +240,10 @@ func (m *txSortedMap) Flatten() types.Transactions { // transaction with the highest nonce func (m *txSortedMap) LastElement() *types.Transaction { cache := m.flatten() + ln := len(cache) + if ln == 0 { + return nil + } return cache[len(cache)-1] } diff --git a/core/tx_pool.go b/core/tx_pool.go index 1f4519768..4783183c1 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -1256,6 +1256,9 @@ func (pool *TxPool) runReorg(done chan struct{}, reset *txpoolResetRequest, dirt // Update all accounts to the latest known pending nonce for addr, list := range pool.pending { highestPending := list.LastElement() + if highestPending == nil { + continue + } pool.pendingNonces.set(addr, highestPending.Nonce()+1) } dropBetweenReorgHistogram.Update(int64(pool.changesSinceReorg))