consider response status and err

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
This commit is contained in:
Ignacio Hagopian 2020-06-16 17:32:03 -03:00
parent 4d0df5d599
commit 35d9de6b6e
No known key found for this signature in database
GPG Key ID: 4DC349E20B2AD1BE
2 changed files with 13 additions and 0 deletions

View File

@ -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),

View File

@ -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 = ""
case retrievalmarket.QueryResponseUnavailable:
errStr = "retrieval query offer was unavailable"
case retrievalmarket.QueryResponseError:
errStr = "retrieval query offer errored"
}
return api.QueryOffer{
Root: payload,
@ -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,
}
}