Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
093f512c
Commit
093f512c
authored
6 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
[enh] add `dump blocks [pattern]` and `dump forks [pattern]` commands
parent
a8022b58
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/lib/dal/indexDAL/abstract/software/ForksDAO.ts
+7
-0
7 additions, 0 deletions
app/lib/dal/indexDAL/abstract/software/ForksDAO.ts
app/modules/dump.ts
+9
-0
9 additions, 0 deletions
app/modules/dump.ts
app/modules/dump/blocks/dump.blocks.ts
+26
-0
26 additions, 0 deletions
app/modules/dump/blocks/dump.blocks.ts
with
42 additions
and
0 deletions
app/lib/dal/indexDAL/abstract/software/ForksDAO.ts
+
7
−
0
View file @
093f512c
...
@@ -23,6 +23,13 @@ export interface ForksDAO {
...
@@ -23,6 +23,13 @@ export interface ForksDAO {
getNextForkBlocks
(
number
:
number
,
hash
:
string
):
Promise
<
DBBlock
[]
>
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
[]
>
getPotentialForkBlocks
(
numberStart
:
number
,
medianTimeStart
:
number
,
maxNumber
:
number
):
Promise
<
DBBlock
[]
>
removeForkBlock
(
number
:
number
):
Promise
<
void
>
removeForkBlock
(
number
:
number
):
Promise
<
void
>
...
...
This diff is collapsed.
Click to expand it.
app/modules/dump.ts
+
9
−
0
View file @
093f512c
...
@@ -21,6 +21,7 @@ import {Underscore} from "../lib/common-libs/underscore"
...
@@ -21,6 +21,7 @@ import {Underscore} from "../lib/common-libs/underscore"
import
{
dumpWotWizard
}
from
"
./dump/wotwizard/wotwizard.dump
"
import
{
dumpWotWizard
}
from
"
./dump/wotwizard/wotwizard.dump
"
import
{
OtherConstants
}
from
"
../lib/other_constants
"
import
{
OtherConstants
}
from
"
../lib/other_constants
"
import
{
Querable
,
querablep
}
from
"
../lib/common-libs/querable
"
import
{
Querable
,
querablep
}
from
"
../lib/common-libs/querable
"
import
{
dumpBlocks
,
dumpForks
}
from
"
./dump/blocks/dump.blocks
"
const
Table
=
require
(
'
cli-table
'
)
const
Table
=
require
(
'
cli-table
'
)
...
@@ -71,6 +72,14 @@ module.exports = {
...
@@ -71,6 +72,14 @@ module.exports = {
await
dumpCurrent
(
server
)
await
dumpCurrent
(
server
)
break
break
case
'
blocks
'
:
await
dumpBlocks
(
server
,
name
)
break
case
'
forks
'
:
await
dumpForks
(
server
,
name
)
break
case
'
volumes
'
:
case
'
volumes
'
:
await
dumpVolumes
(
server
)
await
dumpVolumes
(
server
)
break
break
...
...
This diff is collapsed.
Click to expand it.
app/modules/dump/blocks/dump.blocks.ts
0 → 100644
+
26
−
0
View file @
093f512c
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
)
{
console
.
log
(
BlockDTO
.
fromJSONObject
(
b
).
getRawSigned
())
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment