fix skipping during syc

This commit is contained in:
Matias Alejo Garcia 2014-01-20 15:41:22 -03:00
parent 5468895e34
commit b4936fd6b4
1 changed files with 7 additions and 3 deletions

View File

@ -142,13 +142,17 @@ function spec() {
} }
if (opts.upToExisting && existed ) { 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'; self.status = 'finished';
p('DONE. Found existing block: ', blockHash); p('DONE. Found existing block: ', blockHash);
return cb(err); return cb(err);
} }
else { 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 // Continue
if (blockInfo && blockInfo.result) { if (blockInfo && blockInfo.result) {
self.syncInfo.syncedBlocks++; if (! existed) self.syncInfo.syncedBlocks++;
if (opts.prev && blockInfo.result.previousblockhash) { if (opts.prev && blockInfo.result.previousblockhash) {
return self.getPrevNextBlock(blockInfo.result.previousblockhash, blockEnd, opts, cb); return self.getPrevNextBlock(blockInfo.result.previousblockhash, blockEnd, opts, cb);
} }