mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
parent
9acddd1792
commit
0e6d2f4b94
1 changed files with 7 additions and 3 deletions
|
|
@ -125,15 +125,19 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface
|
|||
err := ec.c.CallContext(ctx, &raw, method, args...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if len(raw) == 0 {
|
||||
return nil, ethereum.ErrNotFound
|
||||
}
|
||||
|
||||
// Decode header and transactions.
|
||||
var head *types.Header
|
||||
var body rpcBlock
|
||||
if err := json.Unmarshal(raw, &head); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// When the block is not found, the API returns JSON null.
|
||||
if head == nil {
|
||||
return nil, ethereum.ErrNotFound
|
||||
}
|
||||
|
||||
var body rpcBlock
|
||||
if err := json.Unmarshal(raw, &body); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue