Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

Commit

Permalink
make RemoveTx public
Browse files Browse the repository at this point in the history
  • Loading branch information
calbera committed Apr 27, 2023
1 parent c23aea0 commit 86dbeed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions core/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ func (pool *TxPool) loop() {
if time.Since(pool.beats[addr]) > pool.config.Lifetime {
list := pool.queue[addr].Flatten()
for _, tx := range list {
pool.removeTx(tx.Hash(), true)
pool.RemoveTx(tx.Hash(), true)
}
queuedEvictionMeter.Mark(int64(len(list)))
}
Expand Down Expand Up @@ -465,7 +465,7 @@ func (pool *TxPool) SetGasPrice(price *big.Int) {
// pool.priced is sorted by GasFeeCap, so we have to iterate through pool.all instead
drop := pool.all.RemotesBelowTip(price)
for _, tx := range drop {
pool.removeTx(tx.Hash(), false)
pool.RemoveTx(tx.Hash(), false)
}
pool.priced.Removed(len(drop))
}
Expand Down Expand Up @@ -761,7 +761,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e
for _, tx := range drop {
log.Trace("Discarding freshly underpriced transaction", "hash", tx.Hash(), "gasTipCap", tx.GasTipCap(), "gasFeeCap", tx.GasFeeCap())
underpricedTxMeter.Mark(1)
dropped := pool.removeTx(tx.Hash(), false)
dropped := pool.RemoveTx(tx.Hash(), false)
pool.changesSinceReorg += dropped
}
}
Expand Down Expand Up @@ -1058,10 +1058,10 @@ func (pool *TxPool) Has(hash common.Hash) bool {
return pool.all.Get(hash) != nil
}

// removeTx removes a single transaction from the queue, moving all subsequent
// RemoveTx removes a single transaction from the queue, moving all subsequent
// transactions back to the future queue.
// Returns the number of transactions removed from the pending queue.
func (pool *TxPool) removeTx(hash common.Hash, outofbound bool) int {
func (pool *TxPool) RemoveTx(hash common.Hash, outofbound bool) int {
// Fetch the transaction we wish to delete
tx := pool.all.Get(hash)
if tx == nil {
Expand Down Expand Up @@ -1563,7 +1563,7 @@ func (pool *TxPool) truncateQueue() {
// Drop all transactions if they are less than the overflow
if size := uint64(list.Len()); size <= drop {
for _, tx := range list.Flatten() {
pool.removeTx(tx.Hash(), true)
pool.RemoveTx(tx.Hash(), true)
}
drop -= size
queuedRateLimitMeter.Mark(int64(size))
Expand All @@ -1572,7 +1572,7 @@ func (pool *TxPool) truncateQueue() {
// Otherwise drop only last few transactions
txs := list.Flatten()
for i := len(txs) - 1; i >= 0 && drop > 0; i-- {
pool.removeTx(txs[i].Hash(), true)
pool.RemoveTx(txs[i].Hash(), true)
drop--
queuedRateLimitMeter.Mark(1)
}
Expand Down
2 changes: 1 addition & 1 deletion core/txpool/txpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func TestChainFork(t *testing.T) {
if _, err := pool.add(tx, false); err != nil {
t.Error("didn't expect error", err)
}
pool.removeTx(tx.Hash(), true)
pool.RemoveTx(tx.Hash(), true)

// reset the pool's internal state
resetState()
Expand Down

0 comments on commit 86dbeed

Please sign in to comment.