mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/txpool, miner: add lazy resolver for pending txs too
This commit is contained in:
parent
cdc0e1d865
commit
67bddf61a5
2 changed files with 11 additions and 1 deletions
|
|
@ -30,7 +30,7 @@ import (
|
|||
// enough for the miner and other APIs to handle large batches of transactions;
|
||||
// and supports pulling up the entire transaction when really needed.
|
||||
type LazyTransaction struct {
|
||||
Pool SubPool // Transaction subpool to pull the real transaction up
|
||||
Pool LazyResolver // Transaction resolver to pull the real transaction up
|
||||
Hash common.Hash // Transaction hash to pull up if needed
|
||||
Tx *types.Transaction // Transaction if already resolved
|
||||
|
||||
|
|
@ -51,6 +51,14 @@ func (ltx *LazyTransaction) Resolve() *types.Transaction {
|
|||
return ltx.Tx
|
||||
}
|
||||
|
||||
// LazyResolver is a minimal interface needed for a transaction pool to satisfy
|
||||
// resolving lazy transactions. It's mostly a helper to avoid the entire sub-
|
||||
// pool being injected into the lazy transaction.
|
||||
type LazyResolver interface {
|
||||
// Get returns a transaction if it is contained in the pool, or nil otherwise.
|
||||
Get(hash common.Hash) *types.Transaction
|
||||
}
|
||||
|
||||
// AddressReserver is passed by the main transaction pool to subpools, so they
|
||||
// may request (and relinquish) exclusive access to certain addresses.
|
||||
type AddressReserver func(addr common.Address, reserve bool) error
|
||||
|
|
|
|||
|
|
@ -542,7 +542,9 @@ func (w *worker) mainLoop() {
|
|||
for _, tx := range ev.Txs {
|
||||
acc, _ := types.Sender(w.current.signer, tx)
|
||||
txs[acc] = append(txs[acc], &txpool.LazyTransaction{
|
||||
Pool: w.eth.TxPool(), // We don't know where this came from, yolo resolve from everywhere
|
||||
Hash: tx.Hash(),
|
||||
Tx: nil, // Do *not* set this! We need to resolve it later to pull blobs in
|
||||
Time: tx.Time(),
|
||||
GasFeeCap: tx.GasFeeCap(),
|
||||
GasTipCap: tx.GasTipCap(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue