From 8360336ad2d061d644978677eed39b69052c38ca Mon Sep 17 00:00:00 2001 From: Chris Kleeschulte Date: Thu, 28 Sep 2017 22:00:49 -0400 Subject: [PATCH] Fixed start up of block service. --- lib/services/block/index.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/services/block/index.js b/lib/services/block/index.js index 5bc0fa07..69094e7e 100644 --- a/lib/services/block/index.js +++ b/lib/services/block/index.js @@ -247,6 +247,7 @@ BlockService.prototype._resetTip = function(callback) { } self._tipResetNeeded = false; + var bar = new utils.IndeterminateProgressBar(); log.warn('Block Service: resetting tip due to a non-existent tip block...'); @@ -261,8 +262,13 @@ BlockService.prototype._resetTip = function(callback) { } log.info('Block Service: retrieved all the headers for lookups.'); + async.until(function() { + if (process.stdout.isTTY) { + bar.tick(); + } + return block; }, function(next) { @@ -349,12 +355,14 @@ BlockService.prototype.start = function(callback) { return callback(err); } - if (!tip) { - self._tipResetNeeded = true; - } - self._blockProcessor = async.queue(self._onBlock.bind(self)); self._bus = self.node.openBus({remoteAddress: 'localhost-block'}); + + if (!tip) { + self._tipResetNeeded = true; + return callback(); + } + self._setTip(tip, callback); }); @@ -587,7 +595,9 @@ BlockService.prototype._processReorg = function(commonAncestorHeader, oldTip, ca function() { - bar.tick(); + if (process.stdout.isTTY) { + bar.tick(); + } return tip.hash !== commonAncestorHeader.hash; }, @@ -861,7 +871,7 @@ BlockService.prototype._logProgress = function() { if (bestHeight === 0) { progress = 0; } else { - progress = (this._tip.height/bestHeight*100.00).toFixed(2); + progress = (this._tip.height/bestHeight*100.00).toFixed(4); } log.info('Block Service: download progress: ' + this._tip.height + '/' +