Skip to content

Commit 098b4c7

Browse files
committed
internal/ethapi: remove error return value of RPCMarshalBlock ethereum#27449
1 parent 5cbcdc6 commit 098b4c7

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

eth/api_debug.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ type BadBlockArgs struct {
9090
// and returns them as a JSON list of block-hashes
9191
func (api *DebugAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs, error) {
9292
var (
93-
err error
9493
blocks = rawdb.ReadAllBadBlocks(api.eth.chainDb)
9594
results = make([]*BadBlockArgs, 0, len(blocks))
9695
)
@@ -104,9 +103,7 @@ func (api *DebugAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs, error)
104103
} else {
105104
blockRlp = fmt.Sprintf("%#x", rlpBytes)
106105
}
107-
if blockJSON, err = ethapi.RPCMarshalBlock(block, true, true, api.eth.ApiBackend.ChainConfig()); err != nil {
108-
blockJSON = map[string]interface{}{"error": err.Error()}
109-
}
106+
blockJSON = ethapi.RPCMarshalBlock(block, true, true, api.eth.ApiBackend.ChainConfig())
110107
results = append(results, &BadBlockArgs{
111108
Hash: block.Hash(),
112109
RLP: blockRlp,

internal/ethapi/api.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} {
13401340
// RPCMarshalBlock converts the given block to the RPC output which depends on fullTx. If inclTx is true transactions are
13411341
// returned. When fullTx is true the returned block contains full transaction details, otherwise it will only contain
13421342
// transaction hashes.
1343-
func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *params.ChainConfig) (map[string]interface{}, error) {
1343+
func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *params.ChainConfig) map[string]interface{} {
13441344
fields := RPCMarshalHeader(block.Header())
13451345
fields["size"] = hexutil.Uint64(block.Size())
13461346

@@ -1366,20 +1366,17 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *param
13661366
uncleHashes[i] = uncle.Hash()
13671367
}
13681368
fields["uncles"] = uncleHashes
1369-
return fields, nil
1369+
return fields
13701370
}
13711371

13721372
// rpcMarshalBlock uses the generalized output filler, then adds the total difficulty field, which requires
13731373
// a `BlockChainAPI`.
13741374
func (s *BlockChainAPI) rpcMarshalBlock(ctx context.Context, b *types.Block, inclTx bool, fullTx bool) (map[string]interface{}, error) {
1375-
fields, err := RPCMarshalBlock(b, inclTx, fullTx, s.b.ChainConfig())
1376-
if err != nil {
1377-
return nil, err
1378-
}
1375+
fields := RPCMarshalBlock(b, inclTx, fullTx, s.b.ChainConfig())
13791376
if inclTx {
13801377
fields["totalDifficulty"] = (*hexutil.Big)(s.b.GetTd(ctx, b.Hash()))
13811378
}
1382-
return fields, err
1379+
return fields, nil
13831380
}
13841381

13851382
// findNearestSignedBlock finds the nearest checkpoint from input block

internal/ethapi/api_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,7 @@ func TestRPCMarshalBlock(t *testing.T) {
110110
}
111111

112112
for i, tc := range testSuite {
113-
resp, err := RPCMarshalBlock(block, tc.inclTx, tc.fullTx, params.MainnetChainConfig)
114-
if err != nil {
115-
t.Errorf("test %d: got error %v", i, err)
116-
continue
117-
}
113+
resp := RPCMarshalBlock(block, tc.inclTx, tc.fullTx, params.MainnetChainConfig)
118114
out, err := json.Marshal(resp)
119115
if err != nil {
120116
t.Errorf("test %d: json marshal error: %v", i, err)

0 commit comments

Comments
 (0)