Added report bad transaction (#541)

Co-authored-by: giuliorebuffo <giuliorebuffo@system76-pc.localdomain>
This commit is contained in:
Giulio rebuffo 2022-07-21 23:29:28 +02:00 committed by GitHub
parent 046e4165b5
commit 1331bb661a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -633,6 +633,20 @@ func (p *TxPool) Best(n uint16, txs *types.TxsRlp, tx kv.Tx) error {
return nil
}
// ReportBadTransaction - reports a bad tx in the txpool due for removal.
func (p *TxPool) ReportBadTransaction(txHash [32]byte) {
p.lock.RLock()
defer p.lock.RUnlock()
best := p.pending.best
for i := 0; i < len(best.ms); i++ {
if bytes.Equal(best.ms[i].Tx.IDHash[:], txHash[:]) {
p.pending.Remove(best.ms[i])
return
}
}
}
func (p *TxPool) CountContent() (int, int, int) {
p.lock.RLock()
defer p.lock.RUnlock()