From e8083ed0f7ac0a6ef32646410645677f6661000f Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Mon, 20 Apr 2026 10:01:49 +0200 Subject: [PATCH] eth: fix lint issues after rebase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three files had goimports drift from resolving rebase conflicts (eth/dropper_test.go, eth/fetcher/tx_fetcher.go, eth/handler.go) — re-run goimports. Also remove an unused mockConsumer.count() helper in eth/txtracker/tracker_test.go that no test calls. The method was left in during the peerstats split and never needed. --- eth/dropper_test.go | 18 +++++------ eth/fetcher/tx_fetcher.go | 56 +++++++++++++++++------------------ eth/handler.go | 2 +- eth/txtracker/tracker_test.go | 6 ---- 4 files changed, 38 insertions(+), 44 deletions(-) diff --git a/eth/dropper_test.go b/eth/dropper_test.go index c56f293166..67f24a064d 100644 --- a/eth/dropper_test.go +++ b/eth/dropper_test.go @@ -243,17 +243,17 @@ func TestProtectedByPoolRequestLatencyBasic(t *testing.T) { // Three peers have enough samples; the two fastest should win. stats[dialed[0].ID().String()] = peerstats.PeerStats{ RequestLatencyEMA: 50 * time.Millisecond, - RequestSuccesses: peerstats.MinLatencySamples, + RequestSuccesses: peerstats.MinLatencySamples, LastLatencySample: time.Now(), } stats[dialed[1].ID().String()] = peerstats.PeerStats{ RequestLatencyEMA: 100 * time.Millisecond, - RequestSuccesses: peerstats.MinLatencySamples, + RequestSuccesses: peerstats.MinLatencySamples, LastLatencySample: time.Now(), } stats[dialed[2].ID().String()] = peerstats.PeerStats{ RequestLatencyEMA: 2 * time.Second, - RequestSuccesses: peerstats.MinLatencySamples, + RequestSuccesses: peerstats.MinLatencySamples, LastLatencySample: time.Now(), } @@ -282,12 +282,12 @@ func TestProtectedByPoolRequestLatencyBootstrapGuard(t *testing.T) { // A lucky-fast peer with only 1 sample — must NOT be protected. stats[dialed[0].ID().String()] = peerstats.PeerStats{ RequestLatencyEMA: 1 * time.Millisecond, - RequestSuccesses: 1, + RequestSuccesses: 1, } // A warmed-up but slower peer — should be protected on latency. stats[dialed[1].ID().String()] = peerstats.PeerStats{ RequestLatencyEMA: 500 * time.Millisecond, - RequestSuccesses: peerstats.MinLatencySamples, + RequestSuccesses: peerstats.MinLatencySamples, LastLatencySample: time.Now(), } @@ -317,7 +317,7 @@ func TestProtectedByPoolRequestLatencyPerPool(t *testing.T) { for _, p := range inbound { stats[p.ID().String()] = peerstats.PeerStats{ RequestLatencyEMA: 50 * time.Millisecond, - RequestSuccesses: peerstats.MinLatencySamples, + RequestSuccesses: peerstats.MinLatencySamples, LastLatencySample: time.Now(), } } @@ -326,7 +326,7 @@ func TestProtectedByPoolRequestLatencyPerPool(t *testing.T) { for _, p := range dialed { stats[p.ID().String()] = peerstats.PeerStats{ RequestLatencyEMA: 1 * time.Second, - RequestSuccesses: peerstats.MinLatencySamples, + RequestSuccesses: peerstats.MinLatencySamples, LastLatencySample: time.Now(), } } @@ -356,14 +356,14 @@ func TestProtectedByPoolRequestLatencyStale(t *testing.T) { // Fresh, fast peer — should be protected. stats[dialed[0].ID().String()] = peerstats.PeerStats{ RequestLatencyEMA: 50 * time.Millisecond, - RequestSuccesses: peerstats.MinLatencySamples, + RequestSuccesses: peerstats.MinLatencySamples, LastLatencySample: time.Now(), } // Stale, fast peer — was fast, but hasn't answered in too long. // Same EMA and sample count as the fresh peer; only staleness differs. stats[dialed[1].ID().String()] = peerstats.PeerStats{ RequestLatencyEMA: 50 * time.Millisecond, - RequestSuccesses: peerstats.MinLatencySamples, + RequestSuccesses: peerstats.MinLatencySamples, LastLatencySample: time.Now().Add(-2 * peerstats.MaxLatencyStaleness), } diff --git a/eth/fetcher/tx_fetcher.go b/eth/fetcher/tx_fetcher.go index 6aba3b1f23..b5d0e954e1 100644 --- a/eth/fetcher/tx_fetcher.go +++ b/eth/fetcher/tx_fetcher.go @@ -180,11 +180,11 @@ type TxFetcher struct { alternates map[common.Hash]map[string]struct{} // In-flight transaction alternate origins if retrieval fails // Callbacks - validateMeta func(common.Hash, byte) error // Validate a tx metadata based on the local txpool - addTxs func([]*types.Transaction) []error // Insert a batch of transactions into local txpool - fetchTxs func(string, []common.Hash) error // Retrieves a set of txs from a remote peer - dropPeer func(string) // Drops a peer in case of announcement violation - onAccepted func(peer string, hashes []common.Hash) // Optional: notified with accepted tx hashes per peer + validateMeta func(common.Hash, byte) error // Validate a tx metadata based on the local txpool + addTxs func([]*types.Transaction) []error // Insert a batch of transactions into local txpool + fetchTxs func(string, []common.Hash) error // Retrieves a set of txs from a remote peer + dropPeer func(string) // Drops a peer in case of announcement violation + onAccepted func(peer string, hashes []common.Hash) // Optional: notified with accepted tx hashes per peer onRequestResult func(peer string, latency time.Duration, timeout bool) // Optional: notified once per completed/timed-out tx request step chan struct{} // Notification channel when the fetcher loop iterates @@ -207,30 +207,30 @@ func NewTxFetcherForTests( chain *core.BlockChain, validateMeta func(common.Hash, byte) error, addTxs func([]*types.Transaction) []error, fetchTxs func(string, []common.Hash) error, dropPeer func(string), onAccepted func(string, []common.Hash), onRequestResult func(string, time.Duration, bool), clock mclock.Clock, realTime func() time.Time, rand *mrand.Rand) *TxFetcher { return &TxFetcher{ - notify: make(chan *txAnnounce), - cleanup: make(chan *txDelivery), - drop: make(chan *txDrop), - quit: make(chan struct{}), - waitlist: make(map[common.Hash]map[string]struct{}), - waittime: make(map[common.Hash]mclock.AbsTime), - waitslots: make(map[string]map[common.Hash]*txMetadataWithSeq), - announces: make(map[string]map[common.Hash]*txMetadataWithSeq), - announced: make(map[common.Hash]map[string]struct{}), - fetching: make(map[common.Hash]string), - requests: make(map[string]*txRequest), - alternates: make(map[common.Hash]map[string]struct{}), - underpriced: lru.NewCache[common.Hash, time.Time](maxTxUnderpricedSetSize), - txOnChainCache: lru.NewCache[common.Hash, struct{}](txOnChainCacheLimit), - chain: chain, - validateMeta: validateMeta, - addTxs: addTxs, - fetchTxs: fetchTxs, - dropPeer: dropPeer, - onAccepted: onAccepted, + notify: make(chan *txAnnounce), + cleanup: make(chan *txDelivery), + drop: make(chan *txDrop), + quit: make(chan struct{}), + waitlist: make(map[common.Hash]map[string]struct{}), + waittime: make(map[common.Hash]mclock.AbsTime), + waitslots: make(map[string]map[common.Hash]*txMetadataWithSeq), + announces: make(map[string]map[common.Hash]*txMetadataWithSeq), + announced: make(map[common.Hash]map[string]struct{}), + fetching: make(map[common.Hash]string), + requests: make(map[string]*txRequest), + alternates: make(map[common.Hash]map[string]struct{}), + underpriced: lru.NewCache[common.Hash, time.Time](maxTxUnderpricedSetSize), + txOnChainCache: lru.NewCache[common.Hash, struct{}](txOnChainCacheLimit), + chain: chain, + validateMeta: validateMeta, + addTxs: addTxs, + fetchTxs: fetchTxs, + dropPeer: dropPeer, + onAccepted: onAccepted, onRequestResult: onRequestResult, - clock: clock, - realTime: realTime, - rand: rand, + clock: clock, + realTime: realTime, + rand: rand, } } diff --git a/eth/handler.go b/eth/handler.go index 448cfe0a2a..11b8e79f0f 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -36,9 +36,9 @@ import ( "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/ethereum/go-ethereum/eth/fetcher" + "github.com/ethereum/go-ethereum/eth/peerstats" "github.com/ethereum/go-ethereum/eth/protocols/eth" "github.com/ethereum/go-ethereum/eth/protocols/snap" - "github.com/ethereum/go-ethereum/eth/peerstats" "github.com/ethereum/go-ethereum/eth/txtracker" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" diff --git a/eth/txtracker/tracker_test.go b/eth/txtracker/tracker_test.go index ad0637eb0a..16adb5b92c 100644 --- a/eth/txtracker/tracker_test.go +++ b/eth/txtracker/tracker_test.go @@ -175,12 +175,6 @@ func (c *mockConsumer) last() signal { return c.signals[len(c.signals)-1] } -func (c *mockConsumer) count() int { - c.mu.Lock() - defer c.mu.Unlock() - return len(c.signals) -} - // waitStep blocks until the tracker has processed one event. func waitStep(t *testing.T, tr *Tracker) { t.Helper()