Fixed status
This commit is contained in:
parent
3287af4974
commit
794ae55610
@ -6,6 +6,7 @@ function StatusController(node) {
|
|||||||
this.node = node;
|
this.node = node;
|
||||||
this.common = new Common({log: this.node.log});
|
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) {
|
StatusController.prototype.show = function(req, res) {
|
||||||
@ -68,7 +69,7 @@ StatusController.prototype.getInfo = function(callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
StatusController.prototype.getLastBlockHash = function() {
|
StatusController.prototype.getLastBlockHash = function() {
|
||||||
var hash = this.node.services.bitcoind.tiphash;
|
var hash = this._block.getTip().hash;
|
||||||
return {
|
return {
|
||||||
syncTipHash: hash,
|
syncTipHash: hash,
|
||||||
lastblockhash: hash
|
lastblockhash: hash
|
||||||
@ -76,7 +77,7 @@ StatusController.prototype.getLastBlockHash = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
StatusController.prototype.getBestBlockHash = function(callback) {
|
StatusController.prototype.getBestBlockHash = function(callback) {
|
||||||
this.node.services.bitcoind.getBestBlockHash(function(err, hash) {
|
this._block.getBestBlockHash(function(err, hash) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
@ -87,7 +88,7 @@ StatusController.prototype.getBestBlockHash = function(callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
StatusController.prototype.getDifficulty = function(callback) {
|
StatusController.prototype.getDifficulty = function(callback) {
|
||||||
this.node.services.bitcoind.getInfo(function(err, info) {
|
this._p2p.getInfo(function(err, info) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
@ -101,7 +102,7 @@ StatusController.prototype.sync = function(req, res) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
var status = 'syncing';
|
var status = 'syncing';
|
||||||
|
|
||||||
this.node.services.bitcoind.isSynced(function(err, synced) {
|
this._block.isSynced(function(err, synced) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return self.common.handleErrors(err, res);
|
return self.common.handleErrors(err, res);
|
||||||
}
|
}
|
||||||
@ -109,15 +110,15 @@ StatusController.prototype.sync = function(req, res) {
|
|||||||
status = 'finished';
|
status = 'finished';
|
||||||
}
|
}
|
||||||
|
|
||||||
self.node.services.bitcoind.syncPercentage(function(err, percentage) {
|
self._block.syncPercentage(function(err, percentage) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return self.common.handleErrors(err, res);
|
return self.common.handleErrors(err, res);
|
||||||
}
|
}
|
||||||
var info = {
|
var info = {
|
||||||
status: status,
|
status: status,
|
||||||
blockChainHeight: self.node.services.bitcoind.height,
|
blockChainHeight: self._block.getTip().height,
|
||||||
syncPercentage: Math.round(percentage),
|
syncPercentage: Math.round(percentage),
|
||||||
height: self.node.services.bitcoind.height,
|
height: self._block.getTip().height,
|
||||||
error: null,
|
error: null,
|
||||||
type: 'bitcore node'
|
type: 'bitcore node'
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user