Commit 9da0c902 authored by Cédric Moreau's avatar Cédric Moreau

[fix] #1037 Migrate module "revert"

parent c397ee31
......@@ -15,5 +15,6 @@ app/lib/rules/local_rules.js
app/lib/rules/global_rules.js
app/modules/wizard.js
app/modules/router.js
app/modules/revert.js
test/*.js
test/**/*.js
\ No newline at end of file
......@@ -53,4 +53,5 @@ app/lib/logger*js*
app/service/*.js*
app/lib/wot.js*
app/modules/router*.js*
app/modules/wizard.js*
\ No newline at end of file
app/modules/wizard.js*
app/modules/revert.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: 'revert [count]',
desc: 'Revert (undo + remove) the top [count] blocks from the blockchain. EXPERIMENTAL',
preventIfRunning: true,
onDatabaseExecute: (server, conf, program, params) => co(function*() {
const count = params[0];
const logger = server.logger;
try {
for (let i = 0; i < count; i++) {
yield server.revert();
}
} catch (err) {
logger.error('Error during revert:', err);
}
// Save DB
yield server.disconnect();
})
},{
name: 'revert-to [number]',
desc: 'Revert (undo + remove) top blockchain blocks until block #[number] is reached. EXPERIMENTAL',
onDatabaseExecute: (server, conf, program, params) => co(function*() {
const number = params[0];
const logger = server.logger;
try {
yield server.revertTo(number);
} catch (err) {
logger.error('Error during revert:', err);
}
// Save DB
if (server) {
yield server.disconnect();
}
})
}]
}
}
duniter: {
cli: [{
name: 'revert [count]',
desc: 'Revert (undo + remove) the top [count] blocks from the blockchain. EXPERIMENTAL',
preventIfRunning: true,
onDatabaseExecute: (server, conf, program, params) => __awaiter(this, void 0, void 0, function* () {
const count = params[0];
const logger = server.logger;
try {
for (let i = 0; i < count; i++) {
yield server.revert();
}
}
catch (err) {
logger.error('Error during revert:', err);
}
// Save DB
yield server.disconnect();
})
}, {
name: 'revert-to [number]',
desc: 'Revert (undo + remove) top blockchain blocks until block #[number] is reached. EXPERIMENTAL',
onDatabaseExecute: (server, conf, program, params) => __awaiter(this, void 0, void 0, function* () {
const number = params[0];
const logger = server.logger;
try {
yield server.revertTo(number);
}
catch (err) {
logger.error('Error during revert:', err);
}
// Save DB
if (server) {
yield server.disconnect();
}
})
}]
}
};
//# sourceMappingURL=revert.js.map
\ No newline at end of file
import {ConfDTO} from "../lib/dto/ConfDTO"
module.exports = {
duniter: {
cli: [{
name: 'revert [count]',
desc: 'Revert (undo + remove) the top [count] blocks from the blockchain. EXPERIMENTAL',
preventIfRunning: true,
onDatabaseExecute: async (server:any, conf:ConfDTO, program:any, params:any) => {
const count = params[0];
const logger = server.logger;
try {
for (let i = 0; i < count; i++) {
await server.revert();
}
} catch (err) {
logger.error('Error during revert:', err);
}
// Save DB
await server.disconnect();
}
},{
name: 'revert-to [number]',
desc: 'Revert (undo + remove) top blockchain blocks until block #[number] is reached. EXPERIMENTAL',
onDatabaseExecute: async (server:any, conf:ConfDTO, program:any, params:any) => {
const number = params[0];
const logger = server.logger;
try {
await server.revertTo(number);
} catch (err) {
logger.error('Error during revert:', err);
}
// Save DB
if (server) {
await server.disconnect();
}
}
}]
}
}
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