mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-05 07:42:57 +00:00
graphql: add nil check in block resolver (#33225)
Add nil checks for header and block in Block resolver methods to prevent panic when querying non-existent blocks.
This commit is contained in:
parent
bf141fbfb1
commit
2e5cd21edf
1 changed files with 3 additions and 0 deletions
|
|
@ -707,6 +707,9 @@ func (b *Block) resolveHeader(ctx context.Context) (*types.Header, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if b.header == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
if b.hash == (common.Hash{}) {
|
if b.hash == (common.Hash{}) {
|
||||||
b.hash = b.header.Hash()
|
b.hash = b.header.Hash()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue