retrieval: Fix lint, cli docsgen

This commit is contained in:
Łukasz Magiera 2021-11-16 12:04:03 +01:00
parent ec2bfb99bb
commit 597b72e286
4 changed files with 44 additions and 9 deletions

View File

@ -5,8 +5,6 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr/net"
"io" "io"
"net/http" "net/http"
"net/url" "net/url"
@ -16,21 +14,24 @@ import (
"strings" "strings"
"time" "time"
"github.com/filecoin-project/lotus/node/repo"
"github.com/ipfs/go-blockservice" "github.com/ipfs/go-blockservice"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
offline "github.com/ipfs/go-ipfs-exchange-offline" offline "github.com/ipfs/go-ipfs-exchange-offline"
"github.com/ipfs/go-merkledag" "github.com/ipfs/go-merkledag"
carv2 "github.com/ipld/go-car/v2" carv2 "github.com/ipld/go-car/v2"
"github.com/ipld/go-car/v2/blockstore" "github.com/ipld/go-car/v2/blockstore"
"github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr/net"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-fil-markets/retrievalmarket" "github.com/filecoin-project/go-fil-markets/retrievalmarket"
"github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/big"
lapi "github.com/filecoin-project/lotus/api" lapi "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/repo"
) )
const DefaultMaxRetrievePrice = "0.01" const DefaultMaxRetrievePrice = "0.01"
@ -427,7 +428,7 @@ var clientRetrieveLsCmd = &cli.Command{
} }
if len(roots) != 1 { if len(roots) != 1 {
return xerrors.Errorf("expected 1 car root, got %d") return xerrors.Errorf("expected 1 car root, got %d", len(roots))
} }
dserv := merkledag.NewDAGService(blockservice.New(cbs, offline.Exchange(cbs))) dserv := merkledag.NewDAGService(blockservice.New(cbs, offline.Exchange(cbs)))

View File

@ -539,10 +539,12 @@ NAME:
lotus client retrieve - Retrieve data from network lotus client retrieve - Retrieve data from network
USAGE: USAGE:
lotus client retrieve [command options] [dataCid outputPath] lotus client retrieve command [command options] [dataCid outputPath]
CATEGORY: COMMANDS:
RETRIEVAL cat Show data from network
ls Show object links
help, h Shows a list of commands or help for one command
OPTIONS: OPTIONS:
--from value address to send transactions from --from value address to send transactions from
@ -553,6 +555,33 @@ OPTIONS:
--pieceCid value require data to be retrieved from a specific Piece CID --pieceCid value require data to be retrieved from a specific Piece CID
--allow-local (default: false) --allow-local (default: false)
--help, -h show help (default: false) --help, -h show help (default: false)
--version, -v print the version (default: false)
```
#### lotus client retrieve cat
```
NAME:
lotus client retrieve cat - Show data from network
USAGE:
lotus client retrieve cat [command options] [dataCid]
OPTIONS:
--help, -h show help (default: false)
```
#### lotus client retrieve ls
```
NAME:
lotus client retrieve ls - Show object links
USAGE:
lotus client retrieve ls [command options] [dataCid]
OPTIONS:
--help, -h show help (default: false)
``` ```

View File

@ -323,6 +323,7 @@ func (dh *DealHarness) PerformRetrieval(ctx context.Context, deal *cid.Cid, root
updatesCtx, cancel := context.WithCancel(ctx) updatesCtx, cancel := context.WithCancel(ctx)
updates, err := dh.client.ClientGetRetrievalUpdates(updatesCtx) updates, err := dh.client.ClientGetRetrievalUpdates(updatesCtx)
require.NoError(dh.t, err)
retrievalRes, err := dh.client.ClientRetrieve(ctx, offers[0].Order(caddr)) retrievalRes, err := dh.client.ClientRetrieve(ctx, offers[0].Order(caddr))
require.NoError(dh.t, err) require.NoError(dh.t, err)

View File

@ -1042,6 +1042,8 @@ func parseDagSpec(ctx context.Context, root cid.Cid, dsp []api.DagSpec, ds forma
rsn = selspec.Node() rsn = selspec.Node()
} }
var newRoot cid.Cid
if err := utils.TraverseDag( if err := utils.TraverseDag(
ctx, ctx,
ds, ds,
@ -1059,7 +1061,7 @@ func parseDagSpec(ctx context.Context, root cid.Cid, dsp []api.DagSpec, ds forma
// todo: is this a correct assumption // todo: is this a correct assumption
// todo: is the n ipld.Node above the node we want as the (sub)root? // todo: is the n ipld.Node above the node we want as the (sub)root?
// todo: how to go from ipld.Node to a cid? // todo: how to go from ipld.Node to a cid?
out[i].root = root newRoot = root
return nil return nil
} }
@ -1068,7 +1070,7 @@ func parseDagSpec(ctx context.Context, root cid.Cid, dsp []api.DagSpec, ds forma
return xerrors.Errorf("cidlink cast unexpectedly failed on '%s'", p.LastBlock.Link) return xerrors.Errorf("cidlink cast unexpectedly failed on '%s'", p.LastBlock.Link)
} }
out[i].root = cidLnk.Cid newRoot = cidLnk.Cid
} }
return nil return nil
}, },
@ -1079,6 +1081,8 @@ func parseDagSpec(ctx context.Context, root cid.Cid, dsp []api.DagSpec, ds forma
if out[i].root == cid.Undef { if out[i].root == cid.Undef {
return nil, xerrors.Errorf("path selection does not match a node within %s", root) return nil, xerrors.Errorf("path selection does not match a node within %s", root)
} }
out[i].root = newRoot
} }
if spec.DataSelector != nil { if spec.DataSelector != nil {