diff --git a/app/lib/sync.js b/app/lib/sync.js index 643c4a3b1c268dec46422f86f913d26615a0f8f4..6213d37f6256af616aa1b1efe77c7a9a34344a0c 100644 --- a/app/lib/sync.js +++ b/app/lib/sync.js @@ -43,8 +43,7 @@ module.exports = function Synchroniser (server, host, port, conf, interactive) { timeout: constants.NETWORK.SYNC_LONG_TIMEOUT }; - this.sync = (to, nocautious, nopeers) => { - var cautious = !nocautious, logInterval; + this.sync = (to, askedCautious, nopeers) => { logger.info('Connecting remote host...'); return co(function *() { var node = yield getVucoin(host, port, vucoinOptions); @@ -61,8 +60,11 @@ module.exports = function Synchroniser (server, host, port, conf, interactive) { var localNumber = lCurrent ? lCurrent.number : -1; var remoteNumber = Math.min(rCurrent.number, to || rCurrent.number); + // We use cautious mode if it is asked, or not particulary asked but blockchain has been started + var cautious = (askedCautious === true || (askedCautious === undefined && localNumber >= 0)); + // Recurrent checking - logInterval = setInterval(() => { + setInterval(() => { if (remoteNumber > 1 && speed > 0) { var remain = (remoteNumber - (localNumber + 1 + blocksApplied)); var secondsLeft = remain / speed; diff --git a/bin/ucoind b/bin/ucoind index cb11396b5bf399eceff327d80a95d1d4cf545f38..92df68f223e7795c4cf1c4e684f2daee62968f6a 100755 --- a/bin/ucoind +++ b/bin/ucoind @@ -73,6 +73,7 @@ program .option('--nohttplogs', 'Disable HTTP logs') .option('--nointeractive', 'Disable interactive sync UI') .option('--nocautious', 'Do not check blocks validity during sync') + .option('--cautious', 'Check blocks validity during sync (overrides --nocautious option)') .option('--nopeers', 'Do not retrieve peers during sync') .option('--isolate', 'Avoid the node to send peering or status informations to the network') .option('--check', 'With gen-next: just check validity of generated block') @@ -135,7 +136,14 @@ program function sync(server, host, port, conf, to) { // Synchronize var remote = new Synchroniser(server, host, port, conf, !program.nointeractive); - return remote.sync(parseInt(to), program.nocautious, program.nopeers); + let cautious; + if (program.nocautious) { + cautious = false; + } + if (program.cautious) { + cautious = true; + } + return remote.sync(parseInt(to), cautious, program.nopeers); } program