Skip to content

Commit

Permalink
core/txpool rename tracker -> locals, re-add locals-gauge
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Jan 9, 2025
1 parent 8639d5c commit 3c33b7b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

package tracker
package locals

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

// Package legacypool implements the normal EVM execution transaction pool.
package tracker
// Package locals implements tracking for "local" transactions
package locals

import (
"sync"
Expand All @@ -26,11 +26,15 @@ import (
"github.com/ethereum/go-ethereum/core/txpool/legacypool"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/params"
"golang.org/x/exp/slices"
)

var recheckInterval = time.Minute
var (
recheckInterval = time.Minute
localGauge = metrics.GetOrRegisterGauge("txpool/local", nil)
)

// TxTracker is a struct used to track priority transactions; it will check from
// time to time if the main pool has forgotten about any of the transaction
Expand Down Expand Up @@ -88,11 +92,11 @@ func (tracker *TxTracker) TrackAll(txs []*types.Transaction) {
if _, ok := tracker.all[tx.Hash()]; ok {
continue
}
tracker.all[tx.Hash()] = tx
addr, err := types.Sender(tracker.signer, tx)
if err != nil { // Ignore this tx
continue
}
tracker.all[tx.Hash()] = tx
if tracker.byAddr[addr] == nil {
tracker.byAddr[addr] = legacypool.NewSortedMap()
}
Expand All @@ -101,6 +105,7 @@ func (tracker *TxTracker) TrackAll(txs []*types.Transaction) {
_ = tracker.journal.insert(tx)
}
}
localGauge.Update(int64(len(tracker.all)))
}

// recheck checks and returns any transactions that needs to be resubmitted.
Expand Down Expand Up @@ -142,6 +147,7 @@ func (tracker *TxTracker) recheck(journalCheck bool) (resubmits []*types.Transac
})
}
}
localGauge.Update(int64(len(tracker.all)))
log.Debug("Tx tracker status", "need-resubmit", len(resubmits), "stale", numStales, "ok", numOk)
return resubmits, rejournal
}
Expand Down
6 changes: 3 additions & 3 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"github.com/ethereum/go-ethereum/core/txpool"
"github.com/ethereum/go-ethereum/core/txpool/blobpool"
"github.com/ethereum/go-ethereum/core/txpool/legacypool"
"github.com/ethereum/go-ethereum/core/txpool/tracker"
"github.com/ethereum/go-ethereum/core/txpool/locals"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/eth/downloader"
Expand Down Expand Up @@ -71,7 +71,7 @@ type Ethereum struct {
// core protocol objects
config *ethconfig.Config
txPool *txpool.TxPool
localTxTracker *tracker.TxTracker
localTxTracker *locals.TxTracker
blockchain *core.BlockChain

handler *handler
Expand Down Expand Up @@ -244,7 +244,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
log.Warn("Sanitizing invalid txpool journal time", "provided", rejournal, "updated", time.Second)
rejournal = time.Second
}
eth.localTxTracker = tracker.New(config.TxPool.Journal, rejournal, eth.blockchain.Config(), eth.txPool)
eth.localTxTracker = locals.New(config.TxPool.Journal, rejournal, eth.blockchain.Config(), eth.txPool)
stack.RegisterLifecycle(eth.localTxTracker)
}

Expand Down

0 comments on commit 3c33b7b

Please sign in to comment.