Fix syncComplete calculations
The _lastHeaderCount would always be 2000 behind upon startup, even if it is synced with the last header, causing no more headers to be synced. This fixes the issue that prevented syncing occasionally after restart.
This commit is contained in:
parent
db11257a43
commit
f488a02d2d
@ -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() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user