Commit 50ba4d36 authored by kenshin-samourai's avatar kenshin-samourai

add visual indicator for desynchronized chaintips on status screen

parent 9205ed1c
const statusScript = {
initPage: function() {
this.chaintipBitcoind = 0
this.chaintipIndexer = 0
this.chaintipDb = 0
// Refresh API status
setInterval(() => {this.refreshApiStatus()}, 60000)
// Refresh PushTx status
......@@ -31,6 +34,8 @@ const statusScript = {
const blocks = apiStatus['blocks']
if (blocks) {
this.chaintipBitcoind = blocks
this.chaintipDb = blocks
$('#db-chaintip').text(blocks)
$('#tracker-chaintip').text(blocks)
this.setStatusIndicator('#db-status-ind', 'ok')
......@@ -43,6 +48,7 @@ const statusScript = {
if (apiStatus['indexer']) {
const indexerMaxHeight = apiStatus['indexer']['maxHeight']
if (indexerMaxHeight) {
this.chaintipIndexer = indexerMaxHeight
$('#indexer-chaintip').text(indexerMaxHeight)
this.setStatusIndicator('#indexer-status-ind', 'ok')
} else {
......@@ -55,6 +61,8 @@ const statusScript = {
if (indexerUrl)
$('#indexer-url').text(indexerUrl)
}
this.checkChaintips()
//lib_msg.cleanMessagesUi()
}
}).catch(e => {
......@@ -82,12 +90,14 @@ const statusScript = {
this.setStatusIndicator('#node-status-ind', 'ok')
const uptime = lib_cmn.timePeriod(data['uptime'])
$('#node-uptime').text(uptime)
this.chaintipBitcoind = data['bitcoind']['blocks']
$('#node-chaintip').text(data['bitcoind']['blocks'])
$('#node-version').text(data['bitcoind']['version'])
const network = data['bitcoind']['testnet'] == true ? 'testnet' : 'mainnet'
$('#node-network').text(network)
$('#node-conn').text(data['bitcoind']['conn'])
$('#node-relay-fee').text(data['bitcoind']['relayfee'])
this.checkChaintips()
//lib_msg.cleanMessagesUi()
}
}).catch(e => {
......@@ -96,6 +106,20 @@ const statusScript = {
})
},
checkChaintips: function() {
if (this.chaintipBitcoind > this.chaintipDb) {
this.setStatusIndicator('#db-status-ind', 'desynchronized')
this.setStatusIndicator('#tracker-status-ind', 'desynchronized')
}
if (this.chaintipBitcoind > this.chaintipIndexer) {
this.setStatusIndicator('#indexer-status-ind', 'desynchronized')
} else if (this.chaintipBitcoind < this.chaintipIndexer) {
this.setStatusIndicator('#node-status-ind', 'desynchronized')
this.setStatusIndicator('#db-status-ind', 'desynchronized')
this.setStatusIndicator('#tracker-status-ind', 'desynchronized')
}
},
setStatusIndicator: function(id, status) {
if (status == 'ok') {
$(id).html('&#10003;')
......@@ -103,6 +127,9 @@ const statusScript = {
} else if (status == 'ko') {
$(id).html('X')
$(id).css('color', '#f77c7c')
} else if (status == 'desynchronized') {
$(id).html('&#10003;')
$(id).css('color', '#f0c649')
} else {
$(id).html('-')
$(id).css('color', '#efefef')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment