mirror of
https://github.com/status-im/status-go.git
synced 2025-02-20 02:38:13 +00:00
fix_: bandwidthCounter should be reset each time it is retrieved otherwise it behaves like an accumulator (#5898)
This commit is contained in:
parent
66ee53175e
commit
7a737433d3
@ -519,20 +519,14 @@ func (w *Waku) telemetryBandwidthStats(telemetryServerURL string) {
|
||||
ticker := time.NewTicker(time.Second * 20)
|
||||
defer ticker.Stop()
|
||||
|
||||
today := time.Now()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-w.ctx.Done():
|
||||
return
|
||||
case now := <-ticker.C:
|
||||
// Reset totals when day changes
|
||||
if now.Day() != today.Day() {
|
||||
today = now
|
||||
w.bandwidthCounter.Reset()
|
||||
}
|
||||
|
||||
go telemetry.PushProtocolStats(w.bandwidthCounter.GetBandwidthByProtocol())
|
||||
case <-ticker.C:
|
||||
bandwidthPerProtocol := w.bandwidthCounter.GetBandwidthByProtocol()
|
||||
w.bandwidthCounter.Reset()
|
||||
go telemetry.PushProtocolStats(bandwidthPerProtocol)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user