remove statusData from fetch

This commit is contained in:
alex.sharov 2021-08-14 16:02:27 +07:00
parent 8c5c1bdc52
commit 2206550ae6
2 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -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]