Conversation
imports/api/blocks/server/methods.js
Outdated
| timeDiff = Math.abs(dateLatest.getTime() - dateLast.getTime()); | ||
| // blockTime = (chainStatus.blockTime * (blockData.height - 1) + timeDiff) / blockData.height; | ||
| blockTime = (dateLatest.getTime() - genesisTime.getTime()) / blockData.height; | ||
| blockTime = (height - blockDiff > 0) ? ((dateLatest.getTime() - pastBlockTime.getTime()) / blockDiff) : (dateLatest.getTime() - pastBlockTime.getTime()); |
There was a problem hiding this comment.
@MonikaCat can you explain the whole logic here?
In the original implementation, averageBlcokTime = lastBlockTime - genesisTime / blockHeight. This is always true for the idea of average block time.
There was a problem hiding this comment.
Since the genesis time value had been removed from the settings.json file, we cannot calculate the average block time by using averageBlockTime = lastBlockTime - genesisTime / blockHeight. To handle the calculations, I initially added averageBlockTimeWindow in settings.json file to calculate the average block time of last n blocks...
There was a problem hiding this comment.
However, I changed the approach and I've just updated the code to calculate average block time starting from the startHeight height set in params in settings.json file
There was a problem hiding this comment.
Ah... I have missed the genesisTime in the default_settings.json. It should be there as this is how the average block time is being calculated. Querying from chain is not feasible as the genesis could be huge. The size on cosmoshub-4 can't even give a full response if we query from the api.
There was a problem hiding this comment.
I see! Alright I will update the code to include genesisTime calculations again.
There was a problem hiding this comment.
Updated, how does it do now?
Description
Fixes #542
Checklist
meteor npm run lintCHANGELOG.mdfile.Files changedin the Github PR explorer.