diff --git a/chains/chainMonitor.js b/chains/chainMonitor.js index ce9d384..8bc6b3b 100644 --- a/chains/chainMonitor.js +++ b/chains/chainMonitor.js @@ -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)