mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
fix bug and comments
This commit is contained in:
parent
b07605627f
commit
8b1c1ddfa0
1 changed files with 7 additions and 6 deletions
|
|
@ -88,7 +88,12 @@ func (m *SortedMap) Put(tx *types.Transaction) {
|
||||||
index := slices.IndexFunc(m.cache, func(tx *types.Transaction) bool {
|
index := slices.IndexFunc(m.cache, func(tx *types.Transaction) bool {
|
||||||
return tx.Nonce() == nonce
|
return tx.Nonce() == nonce
|
||||||
})
|
})
|
||||||
m.cache[index] = tx
|
if index == -1 {
|
||||||
|
m.cache = append(m.cache, tx)
|
||||||
|
sort.Sort(types.TxByNonce(m.cache))
|
||||||
|
} else {
|
||||||
|
m.cache[index] = tx
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m.cacheMu.Unlock()
|
m.cacheMu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
@ -200,11 +205,7 @@ func (m *SortedMap) Remove(nonce uint64) bool {
|
||||||
delete(m.items, nonce)
|
delete(m.items, nonce)
|
||||||
|
|
||||||
m.cacheMu.Lock()
|
m.cacheMu.Lock()
|
||||||
if m.cache != nil {
|
m.cache = nil
|
||||||
slices.DeleteFunc(m.cache, func(tx *types.Transaction) bool {
|
|
||||||
return tx.Nonce() == nonce
|
|
||||||
})
|
|
||||||
}
|
|
||||||
m.cacheMu.Unlock()
|
m.cacheMu.Unlock()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue