Update healthcheck.js

This commit is contained in:
Sai Raj 2023-01-05 01:13:04 +05:30 committed by GitHub
parent 3f19804506
commit 8ddc63f647
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,12 +46,14 @@ checks.push(function check_lastBlockTime() {
return resolve(`Last Block not found`);
let last_block_no = data.blocks[0].height;
fetch('https://ranchimallflo.duckdns.org/api/v2.0/flocoreHeight').then(res2 => {
if (!res2.ok || res2.status !== 200)
return resolve(`Get blockchain height fetch with status ${res.status}`);
res2.json().then(data_2 => {
let blockchain_height = data_2.blocks;
if (blockchain_height != last_block_no)
return resolve(`Last Block#${last_block_no}. Blockchain height=${blockchain_height}`);
resolve(true);
}).catch(error => resolve(`Get block height: response not JSON`))
}).catch(error => resolve(`Get blockchain height: response not JSON`))
}).catch(error => reject(error))
}).catch(error => resolve(`Last Block API: response not JSON`))
}).catch(error => reject(error))