Created a task for calculate the avg time for new blocks added#91
Created a task for calculate the avg time for new blocks added#91bezerrablockchain wants to merge 2 commits intodevelopfrom
Conversation
There was a problem hiding this comment.
I would suggest fetching all blocks between the latest block and the reference block (or at least several of them to have better statistical data) and using their timestamps to calculate the average block time. This approach would provide a more accurate average by capturing any variations in block times over the specified range.
At least if I understood the task right
I am not sure! This approach may lead to a period of time that is not reflecting the "actual" processing blocks time. Lets say someone picks up a block with a high network dificulty, this could result in a AVG bigger than just look in the past for an amount of blocks starting by the last one |
tasks/getAvgNewBlockTime.ts
Outdated
| } | ||
|
|
||
| const referenceQuantity = parseInt(referenceBlockQuantity, 10); | ||
| if (!currentBlock) { |
There was a problem hiding this comment.
Why do we add the check the second time?
There was a problem hiding this comment.
Should it be !referenceQuantity?
As requested by Tobby, we should find a more precise way to determine the time between blocks creation