From b4936fd6b4cac61ab98fcd1d141c56a60c05ac9b Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 20 Jan 2014 15:41:22 -0300 Subject: [PATCH] fix skipping during syc --- lib/HistoricSync.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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); }