From 7ed0bae0ec6576debf61ac52719230c68dd84f90 Mon Sep 17 00:00:00 2001 From: Angel Valkov Date: Wed, 8 Jan 2025 12:12:52 +0200 Subject: [PATCH] Additional GRPC API checks --- internal/cli/server/api_service.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/cli/server/api_service.go b/internal/cli/server/api_service.go index 3781b6b45d..5af1a4adf6 100644 --- a/internal/cli/server/api_service.go +++ b/internal/cli/server/api_service.go @@ -49,6 +49,10 @@ func (s *Server) HeaderByNumber(ctx context.Context, req *protobor.GetHeaderByNu return nil, err } + if header == nil { + return nil, errors.New("header not found") + } + return &protobor.GetHeaderByNumberResponse{Header: headerToProtoborHeader(header)}, nil } @@ -62,6 +66,10 @@ func (s *Server) BlockByNumber(ctx context.Context, req *protobor.GetBlockByNumb return nil, err } + if block == nil { + return nil, errors.New("block not found") + } + return &protobor.GetBlockByNumberResponse{Block: blockToProtoBlock(block)}, nil }