internal/api: return empty array rather than nil (#2385)

This commit is contained in:
Eric 2024-04-10 20:13:05 +08:00 committed by GitHub
parent d7836bfe98
commit 009df5a121
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

@ -1018,7 +1018,7 @@ func (s *BlockChainAPI) GetBlobSidecars(ctx context.Context, blockNrOrHash rpc.B
return nil, nil
}
blobSidecars, err := s.b.GetBlobSidecars(ctx, header.Hash())
if err != nil || len(blobSidecars) == 0 {
if err != nil || blobSidecars == nil {
return nil, nil
}
result := make([]map[string]interface{}, len(blobSidecars))
@ -1040,7 +1040,7 @@ func (s *BlockChainAPI) GetBlobSidecarByTxHash(ctx context.Context, hash common.
return nil, nil
}
blobSidecars, err := s.b.GetBlobSidecars(ctx, blockHash)
if err != nil || len(blobSidecars) == 0 {
if err != nil || blobSidecars == nil || len(blobSidecars) == 0 {
return nil, nil
}
for _, sidecar := range blobSidecars {