mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-11 06:23:47 +00:00
parent
a4f1ac1500
commit
c46aae23da
2 changed files with 10 additions and 3 deletions
|
|
@ -351,9 +351,8 @@ func (m *txSortedMap) lastElement() *types.Transaction {
|
||||||
|
|
||||||
m.cacheMu.Unlock()
|
m.cacheMu.Unlock()
|
||||||
|
|
||||||
cache = make(types.Transactions, 0, len(m.items))
|
|
||||||
|
|
||||||
m.m.RLock()
|
m.m.RLock()
|
||||||
|
cache = make(types.Transactions, 0, len(m.items))
|
||||||
|
|
||||||
for _, tx := range m.items {
|
for _, tx := range m.items {
|
||||||
cache = append(cache, tx)
|
cache = append(cache, tx)
|
||||||
|
|
@ -373,6 +372,11 @@ func (m *txSortedMap) lastElement() *types.Transaction {
|
||||||
hitCacheCounter.Inc(1)
|
hitCacheCounter.Inc(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ln := len(cache)
|
||||||
|
if ln == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return cache[len(cache)-1]
|
return cache[len(cache)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1539,6 +1539,7 @@ func (pool *TxPool) runReorg(ctx context.Context, done chan struct{}, reset *txp
|
||||||
// remove any transaction that has been included in the block or was invalidated
|
// remove any transaction that has been included in the block or was invalidated
|
||||||
// because of another transaction (e.g. higher gas price).
|
// because of another transaction (e.g. higher gas price).
|
||||||
|
|
||||||
|
//nolint:nestif
|
||||||
if reset != nil {
|
if reset != nil {
|
||||||
tracing.ElapsedTime(ctx, span, "new block", func(_ context.Context, innerSpan trace.Span) {
|
tracing.ElapsedTime(ctx, span, "new block", func(_ context.Context, innerSpan trace.Span) {
|
||||||
|
|
||||||
|
|
@ -1573,7 +1574,9 @@ func (pool *TxPool) runReorg(ctx context.Context, done chan struct{}, reset *txp
|
||||||
tracing.ElapsedTime(ctx, innerSpan, "09 fill nonces", func(_ context.Context, innerSpan trace.Span) {
|
tracing.ElapsedTime(ctx, innerSpan, "09 fill nonces", func(_ context.Context, innerSpan trace.Span) {
|
||||||
for addr, list := range pool.pending {
|
for addr, list := range pool.pending {
|
||||||
highestPending = list.LastElement()
|
highestPending = list.LastElement()
|
||||||
nonces[addr] = highestPending.Nonce() + 1
|
if highestPending != nil {
|
||||||
|
nonces[addr] = highestPending.Nonce() + 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue