txpool: prevent index out of range 2 (#704)

(Continuation of PR #690)

Fixes the following error reported by stickx:

![PXL_20221024_214752470](https://user-images.githubusercontent.com/34320705/197769120-65e01142-4948-4e04-a555-16675ef9d9f7.jpeg)
This commit is contained in:
Andrew Ashikhmin 2022-10-25 14:18:08 +02:00 committed by GitHub
parent 4fec09660e
commit 3097828465
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2055,7 +2055,9 @@ func (p *PendingPool) Worst() *metaTx { //nolint
}
func (p *PendingPool) PopWorst() *metaTx { //nolint
i := heap.Pop(p.worst).(*metaTx)
p.best.UnsafeRemove(i)
if i.bestIndex >= 0 {
p.best.UnsafeRemove(i)
}
return i
}
func (p *PendingPool) Updated(mt *metaTx) {