Add sizeOnDisk to blockchainInfo

This commit is contained in:
Alex Thomas 2020-03-20 20:59:25 -04:00
parent 7cb3024143
commit c41242ff42
2 changed files with 5 additions and 2 deletions

View File

@ -25,6 +25,7 @@ module.exports.typeDefs = `
blocks: Int blocks: Int
blockTime: Int blockTime: Int
headers: Int headers: Int
sizeOnDisk: String
} }
type MiningInfo { type MiningInfo {

View File

@ -5,17 +5,19 @@ const litecoin = require('litecoin');
module.exports = ({ define }) => { module.exports = ({ define }) => {
define('stats', async (payload, { knex, errors, utils }) => { define('stats', async (payload, { knex, errors, utils }) => {
try { try {
const unrefinedStats = await getNodeStats() const unrefinedStats = await getNodeStats()
// At this point, no error present // At this point, no error present
const unrefinedBlockchainInfo = unrefinedStats[0]; const unrefinedBlockchainInfo = unrefinedStats[0];
// Convert sizeOnDisk to String because number too large
const blockchainInfo = { const blockchainInfo = {
blocks: unrefinedBlockchainInfo.blocks, blocks: unrefinedBlockchainInfo.blocks,
blockTime: unrefinedBlockchainInfo.blockTime, blockTime: unrefinedBlockchainInfo.blockTime,
headers: unrefinedBlockchainInfo.headers headers: unrefinedBlockchainInfo.headers,
sizeOnDisk: unrefinedBlockchainInfo.size_on_disk.toString()
}; };
// Strip miningInfo of unnecessary properties // Strip miningInfo of unnecessary properties