diff --git a/lib/services/header/index.js b/lib/services/header/index.js index 86cb2b3f..4251489b 100644 --- a/lib/services/header/index.js +++ b/lib/services/header/index.js @@ -573,12 +573,15 @@ HeaderService.prototype._startBlockSubscription = function() { }; HeaderService.prototype._syncComplete = function() { + // Check if we have reached the last block that we can download. + var bestHeight = Math.max(this._bestHeight, this._lastHeader.height); - // we always ask for the max number of headers, which is 2000. - // so any response with < 2000 means we have reached the end of the headers list. - // we could make an extra call if the number of total headers is multiple of 2000. - return this._lastHeaderCount < 2000; + var syncComplete = bestHeight === this._tip.height + if (syncComplete) + log.info("Header Service: Sync Complete!") + + return syncComplete }; HeaderService.prototype._setBestHeader = function() {