Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
d65b64c8
Commit
d65b64c8
authored
Jun 06, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow export command to take first and last args
parent
89c9320d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
chaincmd.go
cmd/geth/chaincmd.go
+21
-1
cmd.go
cmd/utils/cmd.go
+15
-0
No files found.
cmd/geth/chaincmd.go
View file @
d65b64c8
...
...
@@ -26,6 +26,12 @@ var (
Action
:
exportChain
,
Name
:
"export"
,
Usage
:
`export blockchain into file`
,
Description
:
`
Requires a first argument of the file to write to.
Optional second and third arguments control the first and
last block to write. In this mode, the file will be appended
if already existing.
`
,
}
upgradedbCommand
=
cli
.
Command
{
Action
:
upgradeDB
,
...
...
@@ -68,7 +74,21 @@ func exportChain(ctx *cli.Context) {
}
chain
,
_
,
_
,
_
:=
utils
.
MakeChain
(
ctx
)
start
:=
time
.
Now
()
if
err
:=
utils
.
ExportChain
(
chain
,
ctx
.
Args
()
.
First
());
err
!=
nil
{
var
err
error
if
len
(
ctx
.
Args
())
<
3
{
err
=
utils
.
ExportChain
(
chain
,
ctx
.
Args
()
.
First
())
}
else
{
// This can be improved to allow for numbers larger than 9223372036854775807
first
,
ferr
:=
strconv
.
ParseInt
(
ctx
.
Args
()
.
Get
(
1
),
10
,
64
)
last
,
lerr
:=
strconv
.
ParseInt
(
ctx
.
Args
()
.
Get
(
2
),
10
,
64
)
if
ferr
!=
nil
||
lerr
!=
nil
{
utils
.
Fatalf
(
"Export error in parsing parameters
\n
"
)
}
err
=
utils
.
ExportAppendChain
(
chain
,
ctx
.
Args
()
.
First
(),
uint64
(
first
),
uint64
(
last
))
}
if
err
!=
nil
{
utils
.
Fatalf
(
"Export error: %v
\n
"
,
err
)
}
fmt
.
Printf
(
"Export done in %v"
,
time
.
Since
(
start
))
...
...
cmd/utils/cmd.go
View file @
d65b64c8
...
...
@@ -268,3 +268,18 @@ func ExportChain(chainmgr *core.ChainManager, fn string) error {
glog
.
Infoln
(
"Exported blockchain to"
,
fn
)
return
nil
}
func
ExportAppendChain
(
chainmgr
*
core
.
ChainManager
,
fn
string
,
first
uint64
,
last
uint64
)
error
{
glog
.
Infoln
(
"Exporting blockchain to"
,
fn
)
// TODO verify mode perms
fh
,
err
:=
os
.
OpenFile
(
fn
,
os
.
O_CREATE
|
os
.
O_APPEND
|
os
.
O_WRONLY
,
os
.
ModePerm
)
if
err
!=
nil
{
return
err
}
defer
fh
.
Close
()
if
err
:=
chainmgr
.
ExportN
(
fh
,
first
,
last
);
err
!=
nil
{
return
err
}
glog
.
Infoln
(
"Exported blockchain to"
,
fn
)
return
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment