Skip to content

Commit

Permalink
fix: check if postage exists before usable check (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrekucci authored Nov 28, 2023
1 parent ac89d0c commit c2f2104
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/bee/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ func (c *Client) CreatePostageBatch(ctx context.Context, amount int64, depth uin
return "", fmt.Errorf("create postage stamp: %w", err)
}

exists := false
usable := false
// wait for the stamp to become usable
for i := 0; i < 300; i++ {
Expand All @@ -387,14 +388,19 @@ func (c *Client) CreatePostageBatch(ctx context.Context, amount int64, depth uin
if err != nil {
continue
}
exists = state.Exists
usable = state.Usable
if usable {
break
}
}

if !exists {
return "", fmt.Errorf("batch %s does not exist", id)
}

if !usable {
return "", fmt.Errorf("timed out waiting for batch %s to activate", id)
return "", fmt.Errorf("batch %s not usable withn given timeout", id)
}

if verbose {
Expand Down

0 comments on commit c2f2104

Please sign in to comment.