Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hivemind
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
hive
hivemind
Commits
290d993c
Commit
290d993c
authored
4 years ago
by
Dariusz Kędzierski
Browse files
Options
Downloads
Patches
Plain Diff
Operation extractor script
parent
b157783d
No related branches found
No related tags found
2 merge requests
!456
Release candidate v1 24
,
!346
Escape characters in user names provided in follow_op
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/operation_extractor.py
+41
-0
41 additions, 0 deletions
scripts/operation_extractor.py
with
41 additions
and
0 deletions
scripts/operation_extractor.py
0 → 100755
+
41
−
0
View file @
290d993c
#!/usr/bin/python3
from
json
import
dumps
from
hive.steem.client
import
SteemClient
if
__name__
==
"
__main__
"
:
import
argparse
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
hivemind_address
"
,
type
=
str
,
help
=
"
Address of hivemind instance
"
)
parser
.
add_argument
(
"
from_block
"
,
type
=
int
,
help
=
"
Scan from block
"
)
parser
.
add_argument
(
"
to_block
"
,
type
=
int
,
help
=
"
Scan to block
"
)
parser
.
add_argument
(
"
output_file
"
,
type
=
str
,
help
=
"
Prepared blocks will be saved in this file
"
)
parser
.
add_argument
(
"
operations
"
,
type
=
str
,
nargs
=
'
+
'
,
help
=
"
Save selected operations
"
)
parser
.
add_argument
(
"
--dump-ops-only
"
,
type
=
bool
,
default
=
False
,
help
=
"
Dump only selected ops without block data
"
)
args
=
parser
.
parse_args
()
client
=
SteemClient
({
"
default
"
:
args
.
hivemind_address
})
from_block
=
args
.
from_block
with
open
(
args
.
output_file
,
"
w
"
)
as
output_file
:
if
not
args
.
dump_ops_only
:
output_file
.
write
(
"
{
\n
"
)
while
from_block
<
args
.
to_block
:
to_block
=
from_block
+
1000
if
to_block
>=
args
.
to_block
:
to_block
=
args
.
to_block
+
1
print
(
"
Processing range from:
"
,
from_block
,
"
to:
"
,
to_block
)
blocks
=
client
.
get_blocks_range
(
from_block
,
to_block
)
for
block
in
blocks
:
block_num
=
int
(
block
[
'
block_id
'
][:
8
],
base
=
16
)
block_data
=
dict
(
block
)
for
idx
in
range
(
len
(
block_data
[
'
transactions
'
])):
block_data
[
'
transactions
'
][
idx
][
'
operations
'
]
=
[
op
for
op
in
block_data
[
'
transactions
'
][
idx
][
'
operations
'
]
if
op
[
'
type
'
]
in
args
.
operations
]
if
args
.
dump_ops_only
and
block_data
[
'
transactions
'
][
idx
][
'
operations
'
]:
output_file
.
write
(
"
{}
\n
"
.
format
(
dumps
(
block_data
[
'
transactions
'
][
idx
][
'
operations
'
])))
if
not
args
.
dump_ops_only
:
output_file
.
write
(
'"
{}
"
:{},
\n
'
.
format
(
block_num
,
dumps
(
block_data
)))
from_block
=
to_block
if
not
args
.
dump_ops_only
:
output_file
.
write
(
"
}
\n
"
)
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