Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider QueryOffer Error & Status #2042

Merged
merged 2 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cli/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ var clientRetrieveCmd = &cli.Command{
return err
}
}
if offer.Err != "" {
return fmt.Errorf("The received offer errored: %s", offer.Err)
}

ref := &lapi.FileRef{
Path: cctx.Args().Get(1),
Expand Down
10 changes: 10 additions & 0 deletions node/impl/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,15 @@ func (a *API) makeRetrievalQuery(ctx context.Context, rp retrievalmarket.Retriev
if err != nil {
return api.QueryOffer{Err: err.Error(), Miner: rp.Address, MinerPeerID: rp.ID}
}
var errStr string
switch queryResponse.Status {
case retrievalmarket.QueryResponseAvailable:
errStr = ""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite it's the default value, preferred to be explicit about the case.

case retrievalmarket.QueryResponseUnavailable:
errStr = "retrieval query offer was unavailable"
case retrievalmarket.QueryResponseError:
errStr = "retrieval query offer errored"
}

return api.QueryOffer{
Root: payload,
Expand All @@ -233,6 +242,7 @@ func (a *API) makeRetrievalQuery(ctx context.Context, rp retrievalmarket.Retriev
PaymentIntervalIncrease: queryResponse.MaxPaymentIntervalIncrease,
Miner: queryResponse.PaymentAddress, // TODO: check
MinerPeerID: rp.ID,
Err: errStr,
}
}

Expand Down