Fixed start up of block service.

This commit is contained in:
Chris Kleeschulte 2017-09-28 22:00:49 -04:00
parent f47b43754c
commit 8360336ad2
No known key found for this signature in database
GPG Key ID: 33195D27EF6BDB7F

View File

@ -247,6 +247,7 @@ BlockService.prototype._resetTip = function(callback) {
} }
self._tipResetNeeded = false; self._tipResetNeeded = false;
var bar = new utils.IndeterminateProgressBar();
log.warn('Block Service: resetting tip due to a non-existent tip block...'); 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.'); log.info('Block Service: retrieved all the headers for lookups.');
async.until(function() { async.until(function() {
if (process.stdout.isTTY) {
bar.tick();
}
return block; return block;
}, function(next) { }, function(next) {
@ -349,12 +355,14 @@ BlockService.prototype.start = function(callback) {
return callback(err); return callback(err);
} }
if (!tip) {
self._tipResetNeeded = true;
}
self._blockProcessor = async.queue(self._onBlock.bind(self)); self._blockProcessor = async.queue(self._onBlock.bind(self));
self._bus = self.node.openBus({remoteAddress: 'localhost-block'}); self._bus = self.node.openBus({remoteAddress: 'localhost-block'});
if (!tip) {
self._tipResetNeeded = true;
return callback();
}
self._setTip(tip, callback); self._setTip(tip, callback);
}); });
@ -587,7 +595,9 @@ BlockService.prototype._processReorg = function(commonAncestorHeader, oldTip, ca
function() { function() {
bar.tick(); if (process.stdout.isTTY) {
bar.tick();
}
return tip.hash !== commonAncestorHeader.hash; return tip.hash !== commonAncestorHeader.hash;
}, },
@ -861,7 +871,7 @@ BlockService.prototype._logProgress = function() {
if (bestHeight === 0) { if (bestHeight === 0) {
progress = 0; progress = 0;
} else { } 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 + '/' + log.info('Block Service: download progress: ' + this._tip.height + '/' +