Merge pull request #410 from pnagurny/bug/sync-percentage
Fix sync percentage
This commit is contained in:
commit
2a14955d74
@ -59,10 +59,14 @@ StatusController.prototype.sync = function(req, res) {
|
||||
status = 'finished';
|
||||
}
|
||||
|
||||
// Not exactly the total blockchain height,
|
||||
// but we will reach 100% when our db and bitcoind are both fully synced
|
||||
var totalHeight = this.node.services.bitcoind.height / (this.node.services.bitcoind.syncPercentage() / 100);
|
||||
|
||||
var info = {
|
||||
status: status,
|
||||
blockChainHeight: this.node.services.bitcoind.height,
|
||||
syncPercentage: this.node.services.db.tip.__height / this.node.services.bitcoind.height * 100,
|
||||
syncPercentage: Math.round(this.node.services.db.tip.__height / totalHeight * 100),
|
||||
height: this.node.services.db.tip.__height,
|
||||
error: null,
|
||||
type: 'bitcore node'
|
||||
|
||||
@ -125,7 +125,8 @@ describe('Status', function() {
|
||||
},
|
||||
bitcoind: {
|
||||
height: 500000,
|
||||
isSynced: sinon.stub().returns(true)
|
||||
isSynced: sinon.stub().returns(true),
|
||||
syncPercentage: sinon.stub().returns(99.99)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user