diff --git a/src/graphql/graphqlModules/Node/NodeStats.js b/src/graphql/graphqlModules/Node/NodeStats.js index d41bf8d..d6bf41e 100644 --- a/src/graphql/graphqlModules/Node/NodeStats.js +++ b/src/graphql/graphqlModules/Node/NodeStats.js @@ -16,10 +16,16 @@ module.exports.typeDefs = ` timestamp: String! blockCount: Int connectionCount: Int + miningInfo: MiningInfo! peerInfo: [PeerInfo!] error: LoadingError } + type MiningInfo { + difficulty: Float + networkhashps: Float + } + type PeerInfo { addr: String subver: String diff --git a/src/store/api/node/nodeStats.js b/src/store/api/node/nodeStats.js index 00f6ca2..7d75acf 100644 --- a/src/store/api/node/nodeStats.js +++ b/src/store/api/node/nodeStats.js @@ -11,8 +11,15 @@ module.exports = ({ define }) => { // At this point, no error present + // Strip miningInfo of unnecessary properties + const unrefinedMiningInfo = unrefinedStats[2] + const miningInfo = { + difficulty: unrefinedMiningInfo.difficulty, + networkhashps: unrefinedMiningInfo.networkhashps + } + // Strip peerInfo of unnecessary properties - const unrefinedPeerInfo = unrefinedStats[2] + const unrefinedPeerInfo = unrefinedStats[3] const peerInfo = unrefinedPeerInfo.map(({ addr, subver }) => ({ addr, subver @@ -22,6 +29,7 @@ module.exports = ({ define }) => { const stats = { blockCount: unrefinedStats[0], connectionCount: unrefinedStats[1], + miningInfo: miningInfo, peerInfo: peerInfo, error: null } @@ -84,6 +92,20 @@ function getNodeStats () { }) }) + const getMiningInfoPromise = new Promise((resolve, reject) => { + litecoinClient.getMiningInfo((error, miningInfo) => { + if (error) { + reject(error) + } else { + try { + resolve(miningInfo) + } catch (error) { + reject(error) + } + } + }) + }) + const getPeerInfoPromise = new Promise((resolve, reject) => { litecoinClient.getPeerInfo((error, peerInfo) => { if (error) { @@ -102,6 +124,7 @@ function getNodeStats () { [ getBlockCountPromise, getConnectionCountPromise, + getMiningInfoPromise, getPeerInfoPromise ] )