diff --git a/lib/HistoricSync.js b/lib/HistoricSync.js index 4b8dcf3f..40706e30 100644 --- a/lib/HistoricSync.js +++ b/lib/HistoricSync.js @@ -90,6 +90,7 @@ function spec() { HistoricSync.prototype.info = function() { + this.updatePercentage(); return { status: this.status, blockChainHeight: this.blockChainHeight, @@ -103,6 +104,12 @@ function spec() { }; }; + HistoricSync.prototype.updatePercentage = function() { + var r = (this.syncedBlocks + this.skippedBlocks) / this.blockChainHeight; + this.syncPercentage = parseFloat(100 * r).toFixed(3); + if (this.syncPercentage > 100) this.syncPercentage = 100; + }; + HistoricSync.prototype.showProgress = function() { var self = this; @@ -112,9 +119,6 @@ function spec() { p('ERROR: ' + self.error); } else { - self.syncPercentage = parseFloat(100 * (self.syncedBlocks + self.skippedBlocks) / self.blockChainHeight).toFixed(3); - if (self.syncPercentage > 100) self.syncPercentage = 100; - p(util.format('status: [%d%%] skipped: %d ', self.syncPercentage, self.skippedBlocks)); } if (self.opts.shouldBroadcastSync) {