Skip to content

Commit

Permalink
Merge pull request #38 from eco-stake/update-rest-block-url
Browse files Browse the repository at this point in the history
Update REST blocks path
  • Loading branch information
tombeynon authored Oct 3, 2022
2 parents c4dc4ba + 9aa1a4a commit b496808
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions chains/blockMonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function BlockMonitor() {
async function fetchCurrentBlock(client, chain){
try {
const restUrl = await getRestUrl(chain)
const block = await got.get(`${restUrl}blocks/latest`, gotOpts).json()
const block = await got.get(`${restUrl}cosmos/base/tendermint/v1beta1/blocks/latest`, gotOpts).json()
await setCurrentBlock(client, chain, block.block, restUrl)
} catch (error) {
timeStamp(chain.path, 'Block update failed', error.message)
Expand All @@ -100,7 +100,7 @@ function BlockMonitor() {
if(!restUrl){
restUrl = await getRestUrl(chain)
}
block = await got.get(`${restUrl}blocks/${height}`, gotOpts).json()
block = await got.get(`${restUrl}cosmos/base/tendermint/v1beta1/blocks/${height}`, gotOpts).json()
await setBlock(client, chain, block.block)
if(currentHeight - height < MAX_BLOCKS){
return fetchBlock(client, chain, currentHeight, height - 1, restUrl)
Expand Down
4 changes: 2 additions & 2 deletions chains/chainMonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ function ChainMonitor() {

async function getBlockParams(restUrl, chain) {
try {
const currentBlock = await got.get(restUrl + 'blocks/latest', gotOpts).json()
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 + 'blocks/' + (currentBlockHeight - 100), gotOpts).json()
const prevBlock = await got.get(`${restUrl}cosmos/base/tendermint/v1beta1/blocks/${currentBlockHeight - 100}`, 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
2 changes: 1 addition & 1 deletion status/healthMonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function HealthMonitor() {
case "rest":
case "private-rest":
case "service":
return 'blocks/latest'
return 'cosmos/base/tendermint/v1beta1/blocks/latest'
case "rpc":
case "private-rpc":
return "block"
Expand Down

0 comments on commit b496808

Please sign in to comment.