From 794ae5561046643252c6615bbae5c3df64527e6c Mon Sep 17 00:00:00 2001 From: Chris Kleeschulte Date: Fri, 18 Aug 2017 20:09:11 +0000 Subject: [PATCH] Fixed status --- lib/status.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/status.js b/lib/status.js index 4aead19..de01be3 100644 --- a/lib/status.js +++ b/lib/status.js @@ -5,7 +5,8 @@ var Common = require('./common'); function StatusController(node) { this.node = node; this.common = new Common({log: this.node.log}); - this._header = this.node.services.header; + this._header = this.node.services.header; + this._block = this.node.services.block; } StatusController.prototype.show = function(req, res) { @@ -68,7 +69,7 @@ StatusController.prototype.getInfo = function(callback) { }; StatusController.prototype.getLastBlockHash = function() { - var hash = this.node.services.bitcoind.tiphash; + var hash = this._block.getTip().hash; return { syncTipHash: hash, lastblockhash: hash @@ -76,7 +77,7 @@ StatusController.prototype.getLastBlockHash = function() { }; StatusController.prototype.getBestBlockHash = function(callback) { - this.node.services.bitcoind.getBestBlockHash(function(err, hash) { + this._block.getBestBlockHash(function(err, hash) { if (err) { return callback(err); } @@ -87,7 +88,7 @@ StatusController.prototype.getBestBlockHash = function(callback) { }; StatusController.prototype.getDifficulty = function(callback) { - this.node.services.bitcoind.getInfo(function(err, info) { + this._p2p.getInfo(function(err, info) { if (err) { return callback(err); } @@ -101,7 +102,7 @@ StatusController.prototype.sync = function(req, res) { var self = this; var status = 'syncing'; - this.node.services.bitcoind.isSynced(function(err, synced) { + this._block.isSynced(function(err, synced) { if (err) { return self.common.handleErrors(err, res); } @@ -109,15 +110,15 @@ StatusController.prototype.sync = function(req, res) { status = 'finished'; } - self.node.services.bitcoind.syncPercentage(function(err, percentage) { + self._block.syncPercentage(function(err, percentage) { if (err) { return self.common.handleErrors(err, res); } var info = { status: status, - blockChainHeight: self.node.services.bitcoind.height, + blockChainHeight: self._block.getTip().height, syncPercentage: Math.round(percentage), - height: self.node.services.bitcoind.height, + height: self._block.getTip().height, error: null, type: 'bitcore node' };