Merge pull request #858 from filecoin-project/feat/slightly-better-retrieval-errors

slightly improve retrieval errors
This commit is contained in:
Łukasz Magiera 2019-12-11 15:45:49 +01:00 committed by GitHub
commit 6c22abee31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -236,7 +236,7 @@ var clientRetrieveCmd = &cli.Command{
}
if err := api.ClientRetrieve(ctx, offers[0].Order(payer), cctx.Args().Get(1)); err != nil {
return err
return xerrors.Errorf("Retrieval Failed: %w", err)
}
fmt.Println("Success")

View File

@ -100,7 +100,7 @@ type clientStream struct {
func (c *Client) RetrieveUnixfs(ctx context.Context, root cid.Cid, size uint64, total types.BigInt, miner peer.ID, client, minerAddr address.Address, out io.Writer) error {
s, err := c.h.NewStream(ctx, miner, ProtocolID)
if err != nil {
return err
return xerrors.Errorf("failed to open stream to miner for retrieval query: %w", err)
}
defer s.Close()
@ -149,7 +149,6 @@ func (c *Client) RetrieveUnixfs(ctx context.Context, root cid.Cid, size uint64,
cst.offset += toFetch
}
log.Info("RETRIEVE SUCCESSFUL")
return nil
}
@ -173,13 +172,12 @@ func (cst *clientStream) doOneExchange(ctx context.Context, toFetch uint64, out
}
if err := cborutil.WriteCborRPC(cst.stream, deal); err != nil {
return err
return xerrors.Errorf("sending incremental retrieval request: %w", err)
}
var resp DealResponse
if err := cborutil.ReadCborRPC(cst.peeker, &resp); err != nil {
log.Error(err)
return err
return xerrors.Errorf("reading retrieval response: %w", err)
}
if resp.Status != Accepted {