|
|
@ -4,8 +4,12 @@ |
|
|
|
*/ |
|
|
|
'use strict' |
|
|
|
|
|
|
|
const network = require('../lib/bitcoin/network') |
|
|
|
const keys = require('../keys')[network.key] |
|
|
|
const util = require('../lib/util') |
|
|
|
const Logger = require('../lib/logger') |
|
|
|
const db = require('../lib/db/mysql-db-wrapper') |
|
|
|
const remote = require('../lib/remote-importer/remote-importer') |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@ -32,8 +36,31 @@ class Status { |
|
|
|
const memory = `${util.toMb(process.memoryUsage().rss)} MiB` |
|
|
|
|
|
|
|
// Get highest block processed by the tracker
|
|
|
|
const highest = await db.getHighestBlock() |
|
|
|
const dbMaxHeight = highest.blockHeight |
|
|
|
let dbMaxHeight = null |
|
|
|
try { |
|
|
|
const highest = await db.getHighestBlock() |
|
|
|
dbMaxHeight = highest.blockHeight |
|
|
|
} catch(e) { |
|
|
|
Logger.error(e, 'API : Status.getCurrent() :') |
|
|
|
} |
|
|
|
|
|
|
|
// Get info about the indexer
|
|
|
|
const indexerType = keys.indexer.active |
|
|
|
let indexerMaxHeight = null |
|
|
|
let indexerUrl = null |
|
|
|
|
|
|
|
if (indexerType == 'third_party_explorer') { |
|
|
|
indexerUrl = (network.key == 'bitcoin') |
|
|
|
? keys.indexer.oxt |
|
|
|
: keys.indexer.esplora |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
const chaintip = await remote.getChainTipHeight() |
|
|
|
indexerMaxHeight = chaintip['chainTipHeight'] |
|
|
|
} catch(e) { |
|
|
|
Logger.error(e, 'API : Status.getCurrent() :') |
|
|
|
} |
|
|
|
|
|
|
|
return { |
|
|
|
uptime: uptime, |
|
|
@ -43,7 +70,12 @@ class Status { |
|
|
|
sessions: this.sessions, |
|
|
|
max: this.maxConn |
|
|
|
}, |
|
|
|
blocks: dbMaxHeight |
|
|
|
blocks: dbMaxHeight, |
|
|
|
indexer: { |
|
|
|
type: indexerType, |
|
|
|
url: indexerUrl, |
|
|
|
maxHeight: indexerMaxHeight |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|