Skip to content

Commit

Permalink
downloader: show correct rates after restart (#13324)
Browse files Browse the repository at this point in the history
Set initial values `prevStats.BytesDownload` and
`prevStats.BytesCompleted` if they are zero, which can occur if the node
was restarted or launched for first time.
Fix for #13250 and
#13044
  • Loading branch information
dvovk authored Jan 7, 2025
1 parent 04799cb commit e3cb56e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions erigon-lib/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -1973,6 +1973,15 @@ func (d *Downloader) ReCalcStats(interval time.Duration) {
stats.BytesDownload = uint64(connStats.BytesReadData.Int64())
stats.BytesCompleted = uint64(connStats.BytesCompleted.Int64())

// if we have no previous stats, it means that node was restarted and need to set initial values
if prevStats.BytesDownload == 0 {
prevStats.BytesDownload = stats.BytesCompleted
}

if prevStats.BytesCompleted == 0 {
prevStats.BytesCompleted = stats.BytesCompleted
}

lastMetadataReady := stats.MetadataReady

stats.BytesTotal, stats.ConnectionsTotal, stats.MetadataReady = 0, 0, 0
Expand Down

0 comments on commit e3cb56e

Please sign in to comment.