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
66ee2dec
Commit
66ee2dec
authored
Oct 20, 2016
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
internal/ethapi: add debug.chaindbCompact
parent
f2ae2f7e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
api.go
internal/ethapi/api.go
+19
-0
web3ext.go
internal/web3ext/web3ext.go
+4
-0
No files found.
internal/ethapi/api.go
View file @
66ee2dec
...
...
@@ -39,6 +39,7 @@ import (
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/util"
"golang.org/x/net/context"
)
...
...
@@ -1321,6 +1322,24 @@ func (api *PrivateDebugAPI) ChaindbProperty(property string) (string, error) {
return
ldb
.
LDB
()
.
GetProperty
(
property
)
}
func
(
api
*
PrivateDebugAPI
)
ChaindbCompact
()
error
{
ldb
,
ok
:=
api
.
b
.
ChainDb
()
.
(
interface
{
LDB
()
*
leveldb
.
DB
})
if
!
ok
{
return
fmt
.
Errorf
(
"chaindbCompact does not work for memory databases"
)
}
for
b
:=
byte
(
0
);
b
<
255
;
b
++
{
glog
.
V
(
logger
.
Info
)
.
Infof
(
"compacting chain DB range 0x%0.2X-0x%0.2X"
,
b
,
b
+
1
)
err
:=
ldb
.
LDB
()
.
CompactRange
(
util
.
Range
{
Start
:
[]
byte
{
b
},
Limit
:
[]
byte
{
b
+
1
}})
if
err
!=
nil
{
glog
.
Errorf
(
"compaction error: %v"
,
err
)
return
err
}
}
return
nil
}
// SetHead rewinds the head of the blockchain to a previous block.
func
(
api
*
PrivateDebugAPI
)
SetHead
(
number
rpc
.
HexNumber
)
{
api
.
b
.
SetHead
(
uint64
(
number
.
Int64
()))
...
...
internal/web3ext/web3ext.go
View file @
66ee2dec
...
...
@@ -337,6 +337,10 @@ web3._extend({
params: 1,
outputFormatter: console.log
}),
new web3._extend.Method({
name: 'chaindbCompact',
call: 'debug_chaindbCompact',
}),
new web3._extend.Method({
name: 'metrics',
call: 'debug_metrics',
...
...
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