fix skipping during syc
This commit is contained in:
parent
5468895e34
commit
b4936fd6b4
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue