mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
rename DropAllTxs -> DropTransactions for consistency. Add to txpool interface. Make simulated beacon rollback use the new method, fix old hack
This commit is contained in:
parent
2fa5e6255a
commit
8827b3a5cb
5 changed files with 14 additions and 14 deletions
|
|
@ -1715,9 +1715,9 @@ func (p *BlobPool) Status(hash common.Hash) txpool.TxStatus {
|
||||||
return txpool.TxStatusUnknown
|
return txpool.TxStatusUnknown
|
||||||
}
|
}
|
||||||
|
|
||||||
// DropAllTxs implements txpool.SubPool, removing all tracked transactions
|
// DropTransactions implements txpool.SubPool, removing all tracked transactions
|
||||||
// from the blob pool and persistent store.
|
// from the blob pool and persistent store.
|
||||||
func (p *BlobPool) DropAllTxs() {
|
func (p *BlobPool) DropTransactions() {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
defer p.lock.Unlock()
|
defer p.lock.Unlock()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1962,9 +1962,9 @@ func numSlots(tx *types.Transaction) int {
|
||||||
return int((tx.Size() + txSlotSize - 1) / txSlotSize)
|
return int((tx.Size() + txSlotSize - 1) / txSlotSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DropAllTxs implements txpool.SubPool, removing all tracked txs from the pool
|
// DropTransactions implements txpool.SubPool, removing all tracked txs from the pool
|
||||||
// and rotating the journal.
|
// and rotating the journal.
|
||||||
func (p *LegacyPool) DropAllTxs() {
|
func (p *LegacyPool) DropTransactions() {
|
||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
defer p.mu.Unlock()
|
defer p.mu.Unlock()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,6 @@ type SubPool interface {
|
||||||
// identified by their hashes.
|
// identified by their hashes.
|
||||||
Status(hash common.Hash) TxStatus
|
Status(hash common.Hash) TxStatus
|
||||||
|
|
||||||
// DropAllTxs removes all tracked transactions from the pool
|
// DropTransactions removes all tracked transactions from the pool
|
||||||
DropAllTxs()
|
DropTransactions()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -497,3 +497,10 @@ func (p *TxPool) Sync() error {
|
||||||
return errors.New("pool already terminated")
|
return errors.New("pool already terminated")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DropTransactions removes all tracked txs from the subpools.
|
||||||
|
func (p *TxPool) DropTransactions() {
|
||||||
|
for _, subpool := range p.subpools {
|
||||||
|
subpool.DropTransactions()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -34,7 +33,6 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -287,12 +285,7 @@ func (c *SimulatedBeacon) Commit() common.Hash {
|
||||||
|
|
||||||
// Rollback un-sends previously added transactions.
|
// Rollback un-sends previously added transactions.
|
||||||
func (c *SimulatedBeacon) Rollback() {
|
func (c *SimulatedBeacon) Rollback() {
|
||||||
// Flush all transactions from the transaction pools
|
c.eth.TxPool().DropTransactions()
|
||||||
maxUint256 := new(big.Int).Sub(new(big.Int).Lsh(common.Big1, 256), common.Big1)
|
|
||||||
c.eth.TxPool().SetGasTip(maxUint256)
|
|
||||||
// Set the gas tip back to accept new transactions
|
|
||||||
// TODO (Marius van der Wijden): set gas tip to parameter passed by config
|
|
||||||
c.eth.TxPool().SetGasTip(big.NewInt(params.GWei))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fork sets the head to the provided hash.
|
// Fork sets the head to the provided hash.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue