Fixed status

This commit is contained in:
Chris Kleeschulte 2017-08-18 20:09:11 +00:00
parent 3287af4974
commit 794ae55610

View File

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