mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
eth: return null for not-found in BlockByNumberOrHash
This commit is contained in:
parent
99c0ed1154
commit
51a802c66e
1 changed files with 3 additions and 1 deletions
|
|
@ -196,7 +196,9 @@ func (b *EthAPIBackend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash r
|
|||
if hash, ok := blockNrOrHash.Hash(); ok {
|
||||
header := b.eth.blockchain.GetHeaderByHash(hash)
|
||||
if header == nil {
|
||||
return nil, errors.New("header for hash not found")
|
||||
// Return 'null' and no error if block is not found.
|
||||
// This behavior is required by RPC spec.
|
||||
return nil, nil
|
||||
}
|
||||
if blockNrOrHash.RequireCanonical && b.eth.blockchain.GetCanonicalHash(header.Number.Uint64()) != hash {
|
||||
return nil, errors.New("hash is not currently canonical")
|
||||
|
|
|
|||
Loading…
Reference in a new issue