graphql: handle nil block in Raw method

Add a nil check for the resolved block to prevent a panic
when encoding a nil block to RLP bytes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Newt6611 2026-03-01 22:19:57 +08:00
parent 723aae2b4e
commit 23dca0cd78

View file

@ -929,7 +929,7 @@ func (b *Block) RawHeader(ctx context.Context) (hexutil.Bytes, error) {
func (b *Block) Raw(ctx context.Context) (hexutil.Bytes, error) {
block, err := b.resolve(ctx)
if err != nil {
if err != nil || block == nil {
return hexutil.Bytes{}, err
}
return rlp.EncodeToBytes(block)