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
5ac4da36
Unverified
Commit
5ac4da36
authored
Jun 13, 2023
by
hero5512
Committed by
GitHub
Jun 13, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
internal/ethapi: remove error return on RPCMarshalBlock (#27449)
rm error when marshal block to rpc type allen
parent
174d267f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
16 deletions
+6
-16
api_debug.go
eth/api_debug.go
+1
-4
api.go
internal/ethapi/api.go
+4
-7
api_test.go
internal/ethapi/api_test.go
+1
-5
No files found.
eth/api_debug.go
View file @
5ac4da36
...
...
@@ -104,7 +104,6 @@ type BadBlockArgs struct {
// and returns them as a JSON list of block hashes.
func
(
api
*
DebugAPI
)
GetBadBlocks
(
ctx
context
.
Context
)
([]
*
BadBlockArgs
,
error
)
{
var
(
err
error
blocks
=
rawdb
.
ReadAllBadBlocks
(
api
.
eth
.
chainDb
)
results
=
make
([]
*
BadBlockArgs
,
0
,
len
(
blocks
))
)
...
...
@@ -118,9 +117,7 @@ func (api *DebugAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs, error)
}
else
{
blockRlp
=
fmt
.
Sprintf
(
"%#x"
,
rlpBytes
)
}
if
blockJSON
,
err
=
ethapi
.
RPCMarshalBlock
(
block
,
true
,
true
,
api
.
eth
.
APIBackend
.
ChainConfig
());
err
!=
nil
{
blockJSON
=
map
[
string
]
interface
{}{
"error"
:
err
.
Error
()}
}
blockJSON
=
ethapi
.
RPCMarshalBlock
(
block
,
true
,
true
,
api
.
eth
.
APIBackend
.
ChainConfig
())
results
=
append
(
results
,
&
BadBlockArgs
{
Hash
:
block
.
Hash
(),
RLP
:
blockRlp
,
...
...
internal/ethapi/api.go
View file @
5ac4da36
...
...
@@ -1281,7 +1281,7 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} {
// RPCMarshalBlock converts the given block to the RPC output which depends on fullTx. If inclTx is true transactions are
// returned. When fullTx is true the returned block contains full transaction details, otherwise it will only contain
// transaction hashes.
func
RPCMarshalBlock
(
block
*
types
.
Block
,
inclTx
bool
,
fullTx
bool
,
config
*
params
.
ChainConfig
)
(
map
[
string
]
interface
{},
error
)
{
func
RPCMarshalBlock
(
block
*
types
.
Block
,
inclTx
bool
,
fullTx
bool
,
config
*
params
.
ChainConfig
)
map
[
string
]
interface
{}
{
fields
:=
RPCMarshalHeader
(
block
.
Header
())
fields
[
"size"
]
=
hexutil
.
Uint64
(
block
.
Size
())
...
...
@@ -1310,7 +1310,7 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *param
if
block
.
Header
()
.
WithdrawalsHash
!=
nil
{
fields
[
"withdrawals"
]
=
block
.
Withdrawals
()
}
return
fields
,
nil
return
fields
}
// rpcMarshalHeader uses the generalized output filler, then adds the total difficulty field, which requires
...
...
@@ -1324,14 +1324,11 @@ func (s *BlockChainAPI) rpcMarshalHeader(ctx context.Context, header *types.Head
// rpcMarshalBlock uses the generalized output filler, then adds the total difficulty field, which requires
// a `BlockchainAPI`.
func
(
s
*
BlockChainAPI
)
rpcMarshalBlock
(
ctx
context
.
Context
,
b
*
types
.
Block
,
inclTx
bool
,
fullTx
bool
)
(
map
[
string
]
interface
{},
error
)
{
fields
,
err
:=
RPCMarshalBlock
(
b
,
inclTx
,
fullTx
,
s
.
b
.
ChainConfig
())
if
err
!=
nil
{
return
nil
,
err
}
fields
:=
RPCMarshalBlock
(
b
,
inclTx
,
fullTx
,
s
.
b
.
ChainConfig
())
if
inclTx
{
fields
[
"totalDifficulty"
]
=
(
*
hexutil
.
Big
)(
s
.
b
.
GetTd
(
ctx
,
b
.
Hash
()))
}
return
fields
,
err
return
fields
,
nil
}
// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
...
...
internal/ethapi/api_test.go
View file @
5ac4da36
...
...
@@ -758,11 +758,7 @@ func TestRPCMarshalBlock(t *testing.T) {
}
for
i
,
tc
:=
range
testSuite
{
resp
,
err
:=
RPCMarshalBlock
(
block
,
tc
.
inclTx
,
tc
.
fullTx
,
params
.
MainnetChainConfig
)
if
err
!=
nil
{
t
.
Errorf
(
"test %d: got error %v"
,
i
,
err
)
continue
}
resp
:=
RPCMarshalBlock
(
block
,
tc
.
inclTx
,
tc
.
fullTx
,
params
.
MainnetChainConfig
)
out
,
err
:=
json
.
Marshal
(
resp
)
if
err
!=
nil
{
t
.
Errorf
(
"test %d: json marshal error: %v"
,
i
,
err
)
...
...
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