eth: fix lint issues after rebase

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.
This commit is contained in:
Csaba Kiraly 2026-04-20 10:01:49 +02:00
parent a1704238f5
commit 7b4732c197
2 changed files with 38 additions and 38 deletions

View file

@ -243,17 +243,17 @@ func TestProtectedByPoolRequestLatencyBasic(t *testing.T) {
// Three peers have enough samples; the two fastest should win. // Three peers have enough samples; the two fastest should win.
stats[dialed[0].ID().String()] = peerstats.PeerStats{ stats[dialed[0].ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 50 * time.Millisecond, RequestLatencyEMA: 50 * time.Millisecond,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now(), LastLatencySample: time.Now(),
} }
stats[dialed[1].ID().String()] = peerstats.PeerStats{ stats[dialed[1].ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 100 * time.Millisecond, RequestLatencyEMA: 100 * time.Millisecond,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now(), LastLatencySample: time.Now(),
} }
stats[dialed[2].ID().String()] = peerstats.PeerStats{ stats[dialed[2].ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 2 * time.Second, RequestLatencyEMA: 2 * time.Second,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now(), LastLatencySample: time.Now(),
} }
@ -282,12 +282,12 @@ func TestProtectedByPoolRequestLatencyBootstrapGuard(t *testing.T) {
// A lucky-fast peer with only 1 sample — must NOT be protected. // A lucky-fast peer with only 1 sample — must NOT be protected.
stats[dialed[0].ID().String()] = peerstats.PeerStats{ stats[dialed[0].ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 1 * time.Millisecond, RequestLatencyEMA: 1 * time.Millisecond,
RequestSuccesses: 1, RequestSuccesses: 1,
} }
// A warmed-up but slower peer — should be protected on latency. // A warmed-up but slower peer — should be protected on latency.
stats[dialed[1].ID().String()] = peerstats.PeerStats{ stats[dialed[1].ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 500 * time.Millisecond, RequestLatencyEMA: 500 * time.Millisecond,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now(), LastLatencySample: time.Now(),
} }
@ -317,7 +317,7 @@ func TestProtectedByPoolRequestLatencyPerPool(t *testing.T) {
for _, p := range inbound { for _, p := range inbound {
stats[p.ID().String()] = peerstats.PeerStats{ stats[p.ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 50 * time.Millisecond, RequestLatencyEMA: 50 * time.Millisecond,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now(), LastLatencySample: time.Now(),
} }
} }
@ -326,7 +326,7 @@ func TestProtectedByPoolRequestLatencyPerPool(t *testing.T) {
for _, p := range dialed { for _, p := range dialed {
stats[p.ID().String()] = peerstats.PeerStats{ stats[p.ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 1 * time.Second, RequestLatencyEMA: 1 * time.Second,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now(), LastLatencySample: time.Now(),
} }
} }
@ -356,14 +356,14 @@ func TestProtectedByPoolRequestLatencyStale(t *testing.T) {
// Fresh, fast peer — should be protected. // Fresh, fast peer — should be protected.
stats[dialed[0].ID().String()] = peerstats.PeerStats{ stats[dialed[0].ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 50 * time.Millisecond, RequestLatencyEMA: 50 * time.Millisecond,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now(), LastLatencySample: time.Now(),
} }
// Stale, fast peer — was fast, but hasn't answered in too long. // Stale, fast peer — was fast, but hasn't answered in too long.
// Same EMA and sample count as the fresh peer; only staleness differs. // Same EMA and sample count as the fresh peer; only staleness differs.
stats[dialed[1].ID().String()] = peerstats.PeerStats{ stats[dialed[1].ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 50 * time.Millisecond, RequestLatencyEMA: 50 * time.Millisecond,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now().Add(-2 * peerstats.MaxLatencyStaleness), LastLatencySample: time.Now().Add(-2 * peerstats.MaxLatencyStaleness),
} }

View file

@ -183,11 +183,11 @@ type TxFetcher struct {
alternates map[common.Hash]map[string]struct{} // In-flight transaction alternate origins if retrieval fails alternates map[common.Hash]map[string]struct{} // In-flight transaction alternate origins if retrieval fails
// Callbacks // Callbacks
validateMeta func(common.Hash, byte) error // Validate a tx metadata based on the local txpool 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 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 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 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 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 onRequestResult func(peer string, latency time.Duration, timeout bool) // Optional: notified once per completed/timed-out tx request
buffer *blobpool.BlobBuffer buffer *blobpool.BlobBuffer
@ -213,31 +213,31 @@ 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), 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),
buffer *blobpool.BlobBuffer, clock mclock.Clock, realTime func() time.Time, rand *mrand.Rand) *TxFetcher { buffer *blobpool.BlobBuffer, clock mclock.Clock, realTime func() time.Time, rand *mrand.Rand) *TxFetcher {
return &TxFetcher{ return &TxFetcher{
notify: make(chan *txAnnounce), notify: make(chan *txAnnounce),
cleanup: make(chan *txDelivery), cleanup: make(chan *txDelivery),
drop: make(chan *txDrop), drop: make(chan *txDrop),
quit: make(chan struct{}), quit: make(chan struct{}),
waitlist: make(map[common.Hash]map[string]struct{}), waitlist: make(map[common.Hash]map[string]struct{}),
waittime: make(map[common.Hash]mclock.AbsTime), waittime: make(map[common.Hash]mclock.AbsTime),
waitslots: make(map[string]map[common.Hash]*txMetadataWithSeq), waitslots: make(map[string]map[common.Hash]*txMetadataWithSeq),
announces: make(map[string]map[common.Hash]*txMetadataWithSeq), announces: make(map[string]map[common.Hash]*txMetadataWithSeq),
announced: make(map[common.Hash]map[string]struct{}), announced: make(map[common.Hash]map[string]struct{}),
fetching: make(map[common.Hash]string), fetching: make(map[common.Hash]string),
requests: make(map[string]*txRequest), requests: make(map[string]*txRequest),
alternates: make(map[common.Hash]map[string]struct{}), alternates: make(map[common.Hash]map[string]struct{}),
underpriced: lru.NewCache[common.Hash, time.Time](maxTxUnderpricedSetSize), underpriced: lru.NewCache[common.Hash, time.Time](maxTxUnderpricedSetSize),
txOnChainCache: lru.NewCache[common.Hash, struct{}](txOnChainCacheLimit), txOnChainCache: lru.NewCache[common.Hash, struct{}](txOnChainCacheLimit),
chain: chain, chain: chain,
validateMeta: validateMeta, validateMeta: validateMeta,
addTxs: addTxs, addTxs: addTxs,
fetchTxs: fetchTxs, fetchTxs: fetchTxs,
dropPeer: dropPeer, dropPeer: dropPeer,
buffer: buffer, buffer: buffer,
onAccepted: onAccepted, onAccepted: onAccepted,
onRequestResult: onRequestResult, onRequestResult: onRequestResult,
clock: clock, clock: clock,
realTime: realTime, realTime: realTime,
rand: rand, rand: rand,
} }
} }