diff --git a/lib/HistoricSync.js b/lib/HistoricSync.js index f9d3d0a9..b33b4bd8 100644 --- a/lib/HistoricSync.js +++ b/lib/HistoricSync.js @@ -142,13 +142,17 @@ function spec() { } if (opts.upToExisting && existed ) { - if (self.syncInfo.blocksToSync <= self.syncInfo.syncedBlocks) { + var diff = self.syncInfo.blocksToSync - self.syncInfo.syncedBlocks; + if (diff <= 0) { self.status = 'finished'; p('DONE. Found existing block: ', blockHash); return cb(err); } else { - p('WARN found target block\n\tbut blockChain Height is still higher that ours. Previous light sync must be interrupted.\n\tWill keep syncing.', self.syncInfo.syncedBlocks); + self.syncInfo.skipped_blocks = self.syncInfo.skipped_blocks || 1; + if ((self.syncInfo.skipped_blocks++ % 1000) === 1 ) { + p('WARN found target block\n\tbut blockChain Height is still higher that ours. Previous light sync must be interrupted.\n\tWill keep syncing.', self.syncInfo.syncedBlocks, self.syncInfo.blocksToSync, self.syncInfo.skipped_blocks); + } } } @@ -161,7 +165,7 @@ function spec() { // Continue if (blockInfo && blockInfo.result) { - self.syncInfo.syncedBlocks++; + if (! existed) self.syncInfo.syncedBlocks++; if (opts.prev && blockInfo.result.previousblockhash) { return self.getPrevNextBlock(blockInfo.result.previousblockhash, blockEnd, opts, cb); }