Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: RicardoReis on July 30, 2022, 04:38:32 PM



Title: How is “progress per hour” calculated?
Post by: RicardoReis on July 30, 2022, 04:38:32 PM
How is “progress per hour” calculated?

https://i.ibb.co/ZGB6bSY/09369311-B43-E-40-D3-BC78-06-A5-C280-E574.jpg

What would be the shell script code to return this result?


Title: Re: How is progress per hour calculated?
Post by: NotATether on July 31, 2022, 04:25:47 AM
At src/qt/modaloverlaycpp, around line 110:

Code:
progressDelta = blockProcessTime[0].second - sample.second;
timeDelta = blockProcessTime[0].first - sample.first;
progressPerHour = progressDelta / (double) timeDelta * 1000 * 3600;
remainingMSecs = (progressDelta > 0) ? remainingProgress / progressDelta * timeDelta : -1;

The progress per hour and time remaining is updated every 500 milliseconds, or if the same block is still the latest one processed after 500 milliseconds.

The progress and time deltas are calculated by subtracting the last processed block's time and progress by the second last processed block's time and progress (progress per hour is only displayed if there is at least two blocks processed),

then the progress per hour divides the progressDelta by timeDelta and then converts from milliseconds to hours.

As a bonus, it also calculates the remaining milliseconds from these two last blocks (which explains why the remaining time fluctuates wildly with the connection speed) by dividing the remaining progress (calculated above as 1 - progress), by the progress delta and then multiplying that by the timedelta.


Title: Re: How is “progress per hour” calculated?
Post by: RicardoReis on August 03, 2022, 08:40:53 PM

Thanks.  :)