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
a47b8cf6
Unverified
Commit
a47b8cf6
authored
Oct 01, 2021
by
Péter Szilágyi
Committed by
GitHub
Oct 01, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #23670 from karalabe/get-header-rlp
internal/ethapi: support retrieving header RLPs too
parents
f2491c5e
07a5bc1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
api.go
internal/ethapi/api.go
+13
-0
web3ext.go
internal/web3ext/web3ext.go
+5
-0
No files found.
internal/ethapi/api.go
View file @
a47b8cf6
...
...
@@ -1915,6 +1915,19 @@ func NewPublicDebugAPI(b Backend) *PublicDebugAPI {
return
&
PublicDebugAPI
{
b
:
b
}
}
// GetHeaderRlp retrieves the RLP encoded for of a single header.
func
(
api
*
PublicDebugAPI
)
GetHeaderRlp
(
ctx
context
.
Context
,
number
uint64
)
(
string
,
error
)
{
header
,
_
:=
api
.
b
.
HeaderByNumber
(
ctx
,
rpc
.
BlockNumber
(
number
))
if
header
==
nil
{
return
""
,
fmt
.
Errorf
(
"header #%d not found"
,
number
)
}
encoded
,
err
:=
rlp
.
EncodeToBytes
(
header
)
if
err
!=
nil
{
return
""
,
err
}
return
fmt
.
Sprintf
(
"%x"
,
encoded
),
nil
}
// GetBlockRlp retrieves the RLP encoded for of a single block.
func
(
api
*
PublicDebugAPI
)
GetBlockRlp
(
ctx
context
.
Context
,
number
uint64
)
(
string
,
error
)
{
block
,
_
:=
api
.
b
.
BlockByNumber
(
ctx
,
rpc
.
BlockNumber
(
number
))
...
...
internal/web3ext/web3ext.go
View file @
a47b8cf6
...
...
@@ -223,6 +223,11 @@ web3._extend({
params: 1,
outputFormatter: console.log
}),
new web3._extend.Method({
name: 'getHeaderRlp',
call: 'debug_getHeaderRlp',
params: 1
}),
new web3._extend.Method({
name: 'getBlockRlp',
call: 'debug_getBlockRlp',
...
...
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