mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 07:37:20 +00:00
core/txpool: simplify PendingFilter
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
b98b69e9de
commit
d59174fa23
5 changed files with 13 additions and 15 deletions
|
|
@ -1667,7 +1667,7 @@ func (p *BlobPool) drop() {
|
|||
func (p *BlobPool) Pending(filter txpool.PendingFilter) map[common.Address][]*txpool.LazyTransaction {
|
||||
// If only plain transactions are requested, this pool is unsuitable as it
|
||||
// contains none, don't even bother.
|
||||
if filter.OnlyPlainTxs {
|
||||
if !filter.BlobTxs {
|
||||
return nil
|
||||
}
|
||||
// Track the amount of time waiting to retrieve the list of pending blob txs
|
||||
|
|
@ -1688,12 +1688,8 @@ func (p *BlobPool) Pending(filter txpool.PendingFilter) map[common.Address][]*tx
|
|||
for addr, txs := range p.index {
|
||||
lazies := make([]*txpool.LazyTransaction, 0, len(txs))
|
||||
for _, tx := range txs {
|
||||
|
||||
// Skip v0 or v1 blob transactions if not requested
|
||||
if filter.OnlyBlobV0Txs && tx.version != types.BlobSidecarVersion0 {
|
||||
break // skip the rest because of nonce ordering
|
||||
}
|
||||
if filter.OnlyBlobV1Txs && tx.version != types.BlobSidecarVersion1 {
|
||||
// Skip v0 or v1 blob transactions depending on the filter
|
||||
if tx.version != filter.BlobVersion {
|
||||
break // skip the rest because of nonce ordering
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -508,7 +508,7 @@ func (pool *LegacyPool) ContentFrom(addr common.Address) ([]*types.Transaction,
|
|||
func (pool *LegacyPool) Pending(filter txpool.PendingFilter) map[common.Address][]*txpool.LazyTransaction {
|
||||
// If only blob transactions are requested, this pool is unsuitable as it
|
||||
// contains none, don't even bother.
|
||||
if filter.OnlyBlobV0Txs || filter.OnlyBlobV1Txs {
|
||||
if filter.BlobTxs {
|
||||
return nil
|
||||
}
|
||||
pool.mu.Lock()
|
||||
|
|
|
|||
|
|
@ -78,9 +78,10 @@ type PendingFilter struct {
|
|||
BlobFee *uint256.Int // Minimum 4844 blobfee needed to include a blob transaction
|
||||
GasLimitCap uint64 // Maximum gas can be used for a single transaction execution (0 means no limit)
|
||||
|
||||
OnlyPlainTxs bool // Return only plain EVM transactions (peer-join announces, block space filling)
|
||||
OnlyBlobV0Txs bool // Return only V0 encoded blob transactions (block blob-space filling)
|
||||
OnlyBlobV1Txs bool // Return only V1 encoded blob transactions (block blob-space filling)
|
||||
// When BlobTxs true, return only blob transactions (block blob-space filling)
|
||||
// when false, return only non-blob txs (peer-join announces, block space filling)
|
||||
BlobTxs bool
|
||||
BlobVersion byte // Blob tx version to include. 0 means pre-Osaka, 1 means Osaka and later
|
||||
}
|
||||
|
||||
// TxMetadata denotes the metadata of a transaction.
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import (
|
|||
// syncTransactions starts sending all currently pending transactions to the given peer.
|
||||
func (h *handler) syncTransactions(p *eth.Peer) {
|
||||
var hashes []common.Hash
|
||||
for _, batch := range h.txpool.Pending(txpool.PendingFilter{OnlyPlainTxs: true}) {
|
||||
for _, batch := range h.txpool.Pending(txpool.PendingFilter{BlobTxs: false}) {
|
||||
for _, tx := range batch {
|
||||
hashes = append(hashes, tx.Hash)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -481,13 +481,14 @@ func (miner *Miner) fillTransactions(interrupt *atomic.Int32, env *environment)
|
|||
if miner.chainConfig.IsOsaka(env.header.Number, env.header.Time) {
|
||||
filter.GasLimitCap = params.MaxTxGas
|
||||
}
|
||||
filter.OnlyPlainTxs, filter.OnlyBlobV0Txs, filter.OnlyBlobV1Txs = true, false, false
|
||||
filter.BlobTxs = false
|
||||
pendingPlainTxs := miner.txpool.Pending(filter)
|
||||
|
||||
filter.BlobTxs = true
|
||||
if miner.chainConfig.IsOsaka(env.header.Number, env.header.Time) {
|
||||
filter.OnlyPlainTxs, filter.OnlyBlobV0Txs, filter.OnlyBlobV1Txs = false, false, true
|
||||
filter.BlobVersion = types.BlobSidecarVersion1
|
||||
} else {
|
||||
filter.OnlyPlainTxs, filter.OnlyBlobV0Txs, filter.OnlyBlobV1Txs = false, true, false
|
||||
filter.BlobVersion = types.BlobSidecarVersion0
|
||||
}
|
||||
pendingBlobTxs := miner.txpool.Pending(filter)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue