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

[enh] Make `sync` a module

parent fcc0e446
No related branches found
No related tags found
No related merge requests found
...@@ -183,31 +183,6 @@ module.exports = () => { ...@@ -183,31 +183,6 @@ module.exports = () => {
})(step, null); })(step, null);
})); }));
program
.command('sync [host] [port] [to]')
.description('Synchronize blockchain from a remote Duniter node')
.action(subCommand(service(function (host, port, to, server, conf) {
if (!host) {
throw 'Host is required.';
}
if (!port) {
throw 'Port is required.';
}
return co(function *() {
let cautious;
if (program.nocautious) {
cautious = false;
}
if (program.cautious) {
cautious = true;
}
yield server.synchronize(host, port, parseInt(to), 0, !program.nointeractive, cautious, program.nopeers, program.noshuffle);
if (server) {
yield server.disconnect();
}
});
})));
program program
.command('peer [host] [port]') .command('peer [host] [port]')
.description('Exchange peerings with another node') .description('Exchange peerings with another node')
......
...@@ -23,9 +23,43 @@ const configDependency = { ...@@ -23,9 +23,43 @@ const configDependency = {
} }
}; };
const syncDependency = {
duniter: {
cli: [{
name: 'sync [host] [port] [to]',
desc: 'Synchronize blockchain from a remote Duniter node',
onPluggedDALExecute: (server, conf, program, params, startServices, stopServices) => co(function*() {
const host = params[0];
const port = params[1];
const to = params[2];
if (!host) {
throw 'Host is required.';
}
if (!port) {
throw 'Port is required.';
}
let cautious;
if (program.nocautious) {
cautious = false;
}
if (program.cautious) {
cautious = true;
}
yield server.synchronize(host, port, parseInt(to), 0, !program.nointeractive, cautious, program.nopeers, program.noshuffle);
if (server) {
yield server.disconnect();
}
})
}]
}
};
const DEFAULT_DEPENDENCIES = [{ const DEFAULT_DEPENDENCIES = [{
name: 'duniter-config', name: 'duniter-config',
required: configDependency required: configDependency
}, {
name: 'duniter-sync',
required: syncDependency
}]; }];
module.exports = function (home, memory, overConf) { module.exports = function (home, memory, overConf) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment