diff --git a/txpool/fetch.go b/txpool/fetch.go index be5c369ac..0392eb36e 100644 --- a/txpool/fetch.go +++ b/txpool/fetch.go @@ -50,10 +50,12 @@ type Fetch struct { type Timings struct { syncToNewPeersEvery time.Duration + logEvery time.Duration } var DefaultTimings = Timings{ syncToNewPeersEvery: 2 * time.Minute, + logEvery: 30 * time.Second, } // NewFetch creates a new fetch object that will work with given sentry clients. Since the diff --git a/txpool/pool.go b/txpool/pool.go index f5047c158..8270d18dd 100644 --- a/txpool/pool.go +++ b/txpool/pool.go @@ -29,6 +29,7 @@ import ( "github.com/hashicorp/golang-lru/simplelru" "github.com/holiman/uint256" "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/log/v3" "go.uber.org/atomic" ) @@ -160,6 +161,11 @@ func New(newTxs chan Hashes, db kv.RwDB) (*TxPool, error) { }, nil } +func (p *TxPool) logStats() { + p.lock.RLock() + defer p.lock.RUnlock() + log.Info(fmt.Sprintf("[txpool] queues size: pending=%d/%d, baseFee=%d/%d, queued=%d/%d", p.pending.Len(), PendingSubPoolLimit, p.baseFee.Len(), BaseFeeSubPoolLimit, p.pending.Len(), PendingSubPoolLimit)) +} func (p *TxPool) GetRlp(hash []byte) []byte { p.lock.RLock() defer p.lock.RUnlock() @@ -837,6 +843,9 @@ func (p *WorstQueue) Pop() interface{} { // promote/demote transactions // reorgs func BroadcastLoop(ctx context.Context, p *TxPool, newTxs chan Hashes, send *Send, timings Timings) { + logEvery := time.NewTicker(timings.logEvery) + defer logEvery.Stop() + syncToNewPeersEvery := time.NewTicker(timings.syncToNewPeersEvery) defer syncToNewPeersEvery.Stop() @@ -847,6 +856,8 @@ func BroadcastLoop(ctx context.Context, p *TxPool, newTxs chan Hashes, send *Sen select { case <-ctx.Done(): return + case <-logEvery.C: + p.logStats() case h := <-newTxs: // first broadcast all local txs to all peers, then non-local to random sqrt(peersAmount) peers localTxHashes = localTxHashes[:0]