From c2f2104c20a9a10291b330aeb75f3654d6e471cd Mon Sep 17 00:00:00 2001 From: mrekucci Date: Tue, 28 Nov 2023 17:51:22 +0400 Subject: [PATCH] fix: check if postage exists before usable check (#368) --- pkg/bee/client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/bee/client.go b/pkg/bee/client.go index c06a9f90c..438fef8bd 100644 --- a/pkg/bee/client.go +++ b/pkg/bee/client.go @@ -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++ { @@ -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 {