Commit fe918312 authored by Cédric Moreau's avatar Cédric Moreau

[fix] #1037 Migrate modules "reapply" "reset"

parent 9da0c902
......@@ -16,5 +16,7 @@ app/lib/rules/global_rules.js
app/modules/wizard.js
app/modules/router.js
app/modules/revert.js
app/modules/reset.js
app/modules/reapply.js
test/*.js
test/**/*.js
\ No newline at end of file
......@@ -54,4 +54,6 @@ app/service/*.js*
app/lib/wot.js*
app/modules/router*.js*
app/modules/wizard.js*
app/modules/revert.js*
\ No newline at end of file
app/modules/revert.js*
app/modules/reapply.js*
app/modules/reset.js*
\ No newline at end of file
"use strict";
const co = require('co');
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
module.exports = {
duniter: {
cli: [{
name: 'reapply-to [number]',
desc: 'Reapply reverted blocks until block #[number] is reached. EXPERIMENTAL',
preventIfRunning: true,
onDatabaseExecute: (server, conf, program, params) => co(function*() {
const number = params[0];
const logger = server.logger;
try {
yield server.reapplyTo(number);
} catch (err) {
logger.error('Error during reapply:', err);
}
// Save DB
if (server) {
yield server.disconnect();
}
})
}]
}
}
duniter: {
cli: [{
name: 'reapply-to [number]',
desc: 'Reapply reverted blocks until block #[number] is reached. EXPERIMENTAL',
preventIfRunning: true,
onDatabaseExecute: (server, conf, program, params) => __awaiter(this, void 0, void 0, function* () {
const number = params[0];
const logger = server.logger;
try {
yield server.reapplyTo(number);
}
catch (err) {
logger.error('Error during reapply:', err);
}
// Save DB
if (server) {
yield server.disconnect();
}
})
}]
}
};
//# sourceMappingURL=reapply.js.map
\ No newline at end of file
"use strict";
import {ConfDTO} from "../lib/dto/ConfDTO"
module.exports = {
duniter: {
cli: [{
name: 'reapply-to [number]',
desc: 'Reapply reverted blocks until block #[number] is reached. EXPERIMENTAL',
preventIfRunning: true,
onDatabaseExecute: async (server:any, conf:ConfDTO, program:any, params:any) => {
const number = params[0];
const logger = server.logger;
try {
await server.reapplyTo(number);
} catch (err) {
logger.error('Error during reapply:', err);
}
// Save DB
if (server) {
await server.disconnect();
}
}
}]
}
}
"use strict";
const co = require('co');
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const constants = require('../lib/constants');
const wizard = require('../lib/wizard');
const logger = require('../lib/logger').NewLogger('wizard');
module.exports = {
duniter: {
cli: [{
name: 'reset [config|data|peers|tx|stats|all]',
desc: 'Reset configuration, data, peers, transactions or everything in the database',
preventIfRunning: true,
onConfiguredExecute: (server, conf, program, params, wizardTasks) => co(function*() {
const type = params[0];
if (type === 'peers') {
// Needs the DAL plugged
yield server.initDAL();
}
switch (type) {
case 'data':
yield server.resetData();
logger.warn('Data successfully reseted.');
break;
case 'peers':
yield server.resetPeers();
logger.warn('Peers successfully reseted.');
break;
case 'stats':
yield server.resetStats();
logger.warn('Stats successfully reseted.');
break;
case 'config':
yield server.resetConf();
logger.warn('Configuration successfully reseted.');
break;
case 'all':
yield server.resetAll();
logger.warn('Data & Configuration successfully reseted.');
break;
default:
throw constants.ERRORS.CLI_CALLERR_RESET;
}
})
}]
}
duniter: {
cli: [{
name: 'reset [config|data|peers|tx|stats|all]',
desc: 'Reset configuration, data, peers, transactions or everything in the database',
preventIfRunning: true,
onConfiguredExecute: (server, conf, program, params) => __awaiter(this, void 0, void 0, function* () {
const type = params[0];
if (type === 'peers') {
// Needs the DAL plugged
yield server.initDAL();
}
switch (type) {
case 'data':
yield server.resetData();
logger.warn('Data successfully reseted.');
break;
case 'peers':
yield server.resetPeers();
logger.warn('Peers successfully reseted.');
break;
case 'stats':
yield server.resetStats();
logger.warn('Stats successfully reseted.');
break;
case 'config':
yield server.resetConf();
logger.warn('Configuration successfully reseted.');
break;
case 'all':
yield server.resetAll();
logger.warn('Data & Configuration successfully reseted.');
break;
default:
throw constants.ERRORS.CLI_CALLERR_RESET;
}
})
}]
}
};
//# sourceMappingURL=reset.js.map
\ No newline at end of file
"use strict";
import {ConfDTO} from "../lib/dto/ConfDTO"
const constants = require('../lib/constants');
const wizard = require('../lib/wizard');
const logger = require('../lib/logger').NewLogger('wizard');
module.exports = {
duniter: {
cli: [{
name: 'reset [config|data|peers|tx|stats|all]',
desc: 'Reset configuration, data, peers, transactions or everything in the database',
preventIfRunning: true,
onConfiguredExecute: async (server:any, conf:ConfDTO, program:any, params:any) => {
const type = params[0];
if (type === 'peers') {
// Needs the DAL plugged
await server.initDAL();
}
switch (type) {
case 'data':
await server.resetData();
logger.warn('Data successfully reseted.');
break;
case 'peers':
await server.resetPeers();
logger.warn('Peers successfully reseted.');
break;
case 'stats':
await server.resetStats();
logger.warn('Stats successfully reseted.');
break;
case 'config':
await server.resetConf();
logger.warn('Configuration successfully reseted.');
break;
case 'all':
await server.resetAll();
logger.warn('Data & Configuration successfully reseted.');
break;
default:
throw constants.ERRORS.CLI_CALLERR_RESET;
}
}
}]
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment