Skip to content

Commit

Permalink
Only check namespace proof when txs is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJeremyHe committed Jun 12, 2024
1 parent 9699e0e commit 609cfbf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ func (c *Client) FetchTransactionsInBlock(ctx context.Context, blockHeight uint6
if err := c.get(ctx, &res, "availability/block/%d/namespace/%d", blockHeight, namespace); err != nil {
return TransactionsInBlock{}, err
}
if res.Proof == nil {
return TransactionsInBlock{}, fmt.Errorf("field proof of type NamespaceResponse is required")
}

if res.Transactions == nil {
return TransactionsInBlock{}, fmt.Errorf("field transactions of type NamespaceResponse is required")
}
Expand All @@ -81,6 +79,14 @@ func (c *Client) FetchTransactionsInBlock(ctx context.Context, blockHeight uint6
txs = append(txs, tx.Payload)
}

if len(txs) > 0 && res.Proof == nil {
return TransactionsInBlock{}, fmt.Errorf("field proof of type NamespaceResponse is required")
}

if res.Proof == nil {
return TransactionsInBlock{Transactions: txs, Proof: nil}, nil
}

return TransactionsInBlock{
Transactions: txs,
Proof: *res.Proof,
Expand Down

0 comments on commit 609cfbf

Please sign in to comment.