Fixed sanity check when block height is zero.

This commit is contained in:
Chris Kleeschulte 2017-09-25 15:45:15 -04:00
parent 3383771b10
commit b8e73ae238
No known key found for this signature in database
GPG Key ID: 33195D27EF6BDB7F

View File

@ -310,6 +310,11 @@ BlockService.prototype._resetTip = function(callback) {
BlockService.prototype._performSanityCheck = function(tip, callback) {
var self = this;
if (tip.height === 0) {
return callback(null, tip);
}
// is our tip saved in our database? If not, then find the latest block that is in
// in our database and set the tip to that
self._getBlock(tip.hash, function(err, block) {
@ -383,6 +388,7 @@ BlockService.prototype._queueBlock = function(block) {
}
if (Date.now() - self._timeOfLastBestBlockReport > 30000) { // 30 seconds
self._timeOfLastBestBlockReport = Date.now();
log.info('Block Service: The best block hash is: ' + self._tip.hash +
' at height: ' + self._tip.height);
}