Browse Source

add indexer info to /status endpoint

use-env-var-docker
kenshin-samourai 4 years ago
parent
commit
2c9113bb8c
  1. 38
      accounts/status.js
  2. 5
      lib/remote-importer/oxt-wrapper.js

38
accounts/status.js

@ -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
}
}
}

5
lib/remote-importer/oxt-wrapper.js

@ -33,7 +33,10 @@ class OxtWrapper extends Wrapper {
url: `${this.base}${route}`,
method: 'GET',
json: true,
timeout: 15000
timeout: 15000,
headers: {
'User-Agent': 'Dojo'
}
}
// Sets socks proxy agent if required

Loading…
Cancel
Save