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
a1c63e8b
Unverified
Commit
a1c63e8b
authored
Oct 18, 2016
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/geth: compact and print database stats after an import
parent
a64b1b43
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
chaincmd.go
cmd/geth/chaincmd.go
+21
-4
No files found.
cmd/geth/chaincmd.go
View file @
a1c63e8b
...
...
@@ -31,6 +31,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/syndtr/goleveldb/leveldb/util"
"gopkg.in/urfave/cli.v1"
)
...
...
@@ -81,13 +82,29 @@ func importChain(ctx *cli.Context) error {
}
stack
:=
makeFullNode
(
ctx
)
chain
,
chainDb
:=
utils
.
MakeChain
(
ctx
,
stack
)
defer
chainDb
.
Close
()
// Import the chain
start
:=
time
.
Now
()
err
:=
utils
.
ImportChain
(
chain
,
ctx
.
Args
()
.
First
())
chainDb
.
Close
()
if
err
!=
nil
{
if
err
:=
utils
.
ImportChain
(
chain
,
ctx
.
Args
()
.
First
());
err
!=
nil
{
utils
.
Fatalf
(
"Import error: %v"
,
err
)
}
fmt
.
Printf
(
"Import done in %v"
,
time
.
Since
(
start
))
fmt
.
Printf
(
"Import done in %v, compacting...
\n
"
,
time
.
Since
(
start
))
// Compact the entire database to more accurately measure disk io and print the stats
if
db
,
ok
:=
chainDb
.
(
*
ethdb
.
LDBDatabase
);
ok
{
start
=
time
.
Now
()
if
err
:=
db
.
LDB
()
.
CompactRange
(
util
.
Range
{});
err
!=
nil
{
utils
.
Fatalf
(
"Compaction failed: %v"
,
err
)
}
fmt
.
Printf
(
"Compaction done in %v.
\n
"
,
time
.
Since
(
start
))
stats
,
err
:=
db
.
LDB
()
.
GetProperty
(
"leveldb.stats"
)
if
err
!=
nil
{
utils
.
Fatalf
(
"Failed to read database stats: %v"
,
err
)
}
fmt
.
Println
(
stats
)
}
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