@@ -32,6 +32,7 @@ import (
3232 "github.com/opentracing/opentracing-go"
3333 "github.com/opentracing/opentracing-go/ext"
3434 olog "github.com/opentracing/opentracing-go/log"
35+ "golang.org/x/time/rate"
3536)
3637
3738// loggerName is the tree path name of the logger for this package.
@@ -99,6 +100,7 @@ type PushSync struct {
99100 stabilizer stabilization.Subscriber
100101
101102 shallowReceiptTolerance uint8
103+ overDraftRefreshLimiter * rate.Limiter
102104}
103105
104106type receiptResult struct {
@@ -148,6 +150,7 @@ func New(
148150 errSkip : skippeers .NewList (time .Minute ),
149151 stabilizer : stabilizer ,
150152 shallowReceiptTolerance : shallowReceiptTolerance ,
153+ overDraftRefreshLimiter : rate .NewLimiter (rate .Every (time .Second ), 1 ),
151154 }
152155
153156 ps .validStamp = ps .validStampWrapper (validStamp )
@@ -424,7 +427,10 @@ func (ps *PushSync) pushToClosest(ctx context.Context, ch swarm.Chunk, origin bo
424427 continue // there is still an inflight request, wait for it's result
425428 }
426429
427- ps .logger .Debug ("sleeping to refresh overdraft balance" , "chunk_address" , ch .Address ())
430+ ps .metrics .OverdraftRefresh .Inc ()
431+ if ps .overDraftRefreshLimiter .Allow () {
432+ ps .logger .Debug ("sleeping to refresh overdraft balance" )
433+ }
428434
429435 select {
430436 case <- time .After (overDraftRefresh ):
0 commit comments