Check if block is nil to prevent panic (#736)

This commit is contained in:
Dmitry 2023-02-10 13:48:32 +08:00 committed by GitHub
parent c4f33329ea
commit 0ed78b9261
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -628,6 +628,10 @@ func (s *PublicBlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context,
return nil, err
}
if block == nil {
return nil, errors.New("block not found")
}
receipts, err := s.b.GetReceipts(ctx, block.Hash())
if err != nil {
return nil, err