Skip to content
Snippets Groups Projects
Commit fdca7fd1 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

Fix #248 initial sync won't check for rules to be quicker

parent 04a3e2f6
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment