Skip to content

Commit

Permalink
Merge pull request #79 from eco-stake/variable-comparison-blocks
Browse files Browse the repository at this point in the history
Variable block comparison for APR and increase default to 1000
  • Loading branch information
tombeynon authored May 20, 2024
2 parents e2ad5fd + f3146ea commit 570d124
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion chains/chainMonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ function ChainMonitor() {
const currentBlock = await got.get(`${restUrl}cosmos/base/tendermint/v1beta1/blocks/latest`, gotOpts).json()
const currentBlockTime = new Date(currentBlock.block.header.time) / 1000
const currentBlockHeight = currentBlock.block.header.height
const prevBlock = await got.get(`${restUrl}cosmos/base/tendermint/v1beta1/blocks/${currentBlockHeight - 100}`, gotOpts).json()
const blocksToCompare = process.env.BLOCKS_TO_COMPARE || Math.min(1000, currentBlockHeight - 1)
const prevBlock = await got.get(`${restUrl}cosmos/base/tendermint/v1beta1/blocks/${currentBlockHeight - blocksToCompare}`, gotOpts).json()
const prevBlockTime = new Date(prevBlock.block.header.time) / 1000
const prevBlockHeight = prevBlock.block.header.height
const actualBlockTime = (currentBlockTime - prevBlockTime) / (currentBlockHeight - prevBlockHeight)
Expand Down

0 comments on commit 570d124

Please sign in to comment.