Commit 093f512c authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[enh] add `dump blocks [pattern]` and `dump forks [pattern]` commands

parent a8022b58
......@@ -23,6 +23,13 @@ export interface ForksDAO {
getNextForkBlocks(number:number, hash:string): Promise<DBBlock[]>
* Find any fork block whose number is between `numberStart` and `maxNumber`, both included, and whose medianTime is
* >= `medianTimeStart`.
* @param numberStart
* @param medianTimeStart
* @param maxNumber
getPotentialForkBlocks(numberStart:number, medianTimeStart:number, maxNumber:number): Promise<DBBlock[]>
removeForkBlock(number:number): Promise<void>
......@@ -21,6 +21,7 @@ import {Underscore} from "../lib/common-libs/underscore"
import {dumpWotWizard} from "./dump/wotwizard/wotwizard.dump"
import {OtherConstants} from "../lib/other_constants"
import {Querable, querablep} from "../lib/common-libs/querable"
import {dumpBlocks, dumpForks} from "./dump/blocks/dump.blocks"
const Table = require('cli-table')
......@@ -71,6 +72,14 @@ module.exports = {
await dumpCurrent(server)
case 'blocks':
await dumpBlocks(server, name)
case 'forks':
await dumpForks(server, name)
case 'volumes':
await dumpVolumes(server)
import {Server} from "../../../../server"
import {BlockDTO} from "../../../lib/dto/BlockDTO"
import {DBBlock} from "../../../lib/db/DBBlock"
export async function dumpForks(server: Server, blocks: string) {
return dumpBlocks(server, blocks, false)
export async function dumpBlocks(server: Server, blocks: string, showMainBcOnly = true) {
const patterns = blocks.split(',')
for (const p of patterns) {
// Single block to dump
if (p.match(/^\d+$/)) {
const bNumber = parseInt(p)
if (showMainBcOnly) {
dumpBlockIfDefined(await server.dal.getBlock(bNumber))
} else {
(await server.dal.getPotentialForkBlocks(bNumber, 0, bNumber)).forEach(dumpBlockIfDefined)
export function dumpBlockIfDefined(b: DBBlock|undefined|null) {
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