Fix status page: percentage bar shows 100% on complete

This commit is contained in:
Manuel Araoz 2014-02-12 12:57:55 -03:00
parent 72438e78ef
commit d1ef058125
1 changed files with 7 additions and 3 deletions

View File

@ -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) {