diff --git a/assets/assets.go b/assets/assets.go index 3b33293f73b..bb320b4fd7a 100644 --- a/assets/assets.go +++ b/assets/assets.go @@ -44,7 +44,7 @@ func addAssetList(nd *core.IpfsNode, l []string) (cid.Cid, error) { return cid.Cid{}, err } - basePath := path.NewIPFSPath(dirb.Cid()) + basePath := path.FromCid(dirb.Cid()) for _, p := range l { d, err := Asset.ReadFile(p) @@ -69,5 +69,5 @@ func addAssetList(nd *core.IpfsNode, l []string) (cid.Cid, error) { return cid.Cid{}, err } - return basePath.Cid(), nil + return basePath.RootCid(), nil } diff --git a/client/rpc/apifile.go b/client/rpc/apifile.go index 84a9a106f04..7a54995b181 100644 --- a/client/rpc/apifile.go +++ b/client/rpc/apifile.go @@ -15,7 +15,7 @@ import ( const forwardSeekLimit = 1 << 14 // 16k func (api *UnixfsAPI) Get(ctx context.Context, p path.Path) (files.Node, error) { - if p.Namespace().Mutable() { // use resolved path in case we are dealing with IPNS / MFS + if p.Mutable() { // use resolved path in case we are dealing with IPNS / MFS var err error p, _, err = api.core().ResolvePath(ctx, p) if err != nil { @@ -195,13 +195,13 @@ func (it *apiIter) Next() bool { switch it.cur.Type { case unixfs.THAMTShard, unixfs.TMetadata, unixfs.TDirectory: - it.curFile, err = it.core.getDir(it.ctx, path.NewIPFSPath(c), int64(it.cur.Size)) + it.curFile, err = it.core.getDir(it.ctx, path.FromCid(c), int64(it.cur.Size)) if err != nil { it.err = err return false } case unixfs.TFile: - it.curFile, err = it.core.getFile(it.ctx, path.NewIPFSPath(c), int64(it.cur.Size)) + it.curFile, err = it.core.getFile(it.ctx, path.FromCid(c), int64(it.cur.Size)) if err != nil { it.err = err return false diff --git a/client/rpc/dag.go b/client/rpc/dag.go index c5279507f96..b87eed737ae 100644 --- a/client/rpc/dag.go +++ b/client/rpc/dag.go @@ -79,8 +79,8 @@ func (api *httpNodeAdder) add(ctx context.Context, nd format.Node, pin bool) err if err != nil { return err } - if !stat.Path().Cid().Equals(c) { - return fmt.Errorf("cids didn't match - local %s, remote %s", c.String(), stat.Path().Cid().String()) + if !stat.Path().RootCid().Equals(c) { + return fmt.Errorf("cids didn't match - local %s, remote %s", c.String(), stat.Path().RootCid().String()) } return nil } diff --git a/client/rpc/dht.go b/client/rpc/dht.go index 43970e47e79..852c189764c 100644 --- a/client/rpc/dht.go +++ b/client/rpc/dht.go @@ -47,7 +47,7 @@ func (api *DhtAPI) FindProviders(ctx context.Context, p path.Path, opts ...caopt return nil, err } - resp, err := api.core().Request("dht/findprovs", rp.Cid().String()). + resp, err := api.core().Request("dht/findprovs", rp.RootCid().String()). Option("num-providers", options.NumProviders). Send(ctx) if err != nil { @@ -103,7 +103,7 @@ func (api *DhtAPI) Provide(ctx context.Context, p path.Path, opts ...caopts.DhtP return err } - return api.core().Request("dht/provide", rp.Cid().String()). + return api.core().Request("dht/provide", rp.RootCid().String()). Option("recursive", options.Recursive). Exec(ctx, nil) } diff --git a/client/rpc/object.go b/client/rpc/object.go index c2fe8bacef6..7296308a71d 100644 --- a/client/rpc/object.go +++ b/client/rpc/object.go @@ -62,7 +62,7 @@ func (api *ObjectAPI) Put(ctx context.Context, r io.Reader, opts ...caopts.Objec return nil, err } - return path.NewIPFSPath(c), nil + return path.FromCid(c), nil } func (api *ObjectAPI) Get(ctx context.Context, p path.Path) (ipld.Node, error) { @@ -172,7 +172,7 @@ func (api *ObjectAPI) AddLink(ctx context.Context, base path.Path, name string, return nil, err } - return path.NewIPFSPath(c), nil + return path.FromCid(c), nil } func (api *ObjectAPI) RmLink(ctx context.Context, base path.Path, link string) (path.ImmutablePath, error) { @@ -188,7 +188,7 @@ func (api *ObjectAPI) RmLink(ctx context.Context, base path.Path, link string) ( return nil, err } - return path.NewIPFSPath(c), nil + return path.FromCid(c), nil } func (api *ObjectAPI) AppendData(ctx context.Context, p path.Path, r io.Reader) (path.ImmutablePath, error) { @@ -205,7 +205,7 @@ func (api *ObjectAPI) AppendData(ctx context.Context, p path.Path, r io.Reader) return nil, err } - return path.NewIPFSPath(c), nil + return path.FromCid(c), nil } func (api *ObjectAPI) SetData(ctx context.Context, p path.Path, r io.Reader) (path.ImmutablePath, error) { @@ -222,7 +222,7 @@ func (api *ObjectAPI) SetData(ctx context.Context, p path.Path, r io.Reader) (pa return nil, err } - return path.NewIPFSPath(c), nil + return path.FromCid(c), nil } type change struct { @@ -246,10 +246,10 @@ func (api *ObjectAPI) Diff(ctx context.Context, a path.Path, b path.Path) ([]ifa Path: ch.Path, } if ch.Before != cid.Undef { - res[i].Before = path.NewIPFSPath(ch.Before) + res[i].Before = path.FromCid(ch.Before) } if ch.After != cid.Undef { - res[i].After = path.NewIPFSPath(ch.After) + res[i].After = path.FromCid(ch.After) } } return res, nil diff --git a/client/rpc/path.go b/client/rpc/path.go index 6a06a08fde2..558203515a4 100644 --- a/client/rpc/path.go +++ b/client/rpc/path.go @@ -25,7 +25,7 @@ func (api *HttpApi) ResolvePath(ctx context.Context, p path.Path) (path.Immutabl return nil, nil, err } - p, err = path.NewPathFromSegments(p.Namespace().String(), out.Cid.String(), out.RemPath) + p, err = path.NewPathFromSegments(p.Namespace(), out.Cid.String(), out.RemPath) if err != nil { return nil, nil, err } @@ -44,5 +44,5 @@ func (api *HttpApi) ResolveNode(ctx context.Context, p path.Path) (ipld.Node, er return nil, err } - return api.Dag().Get(ctx, rp.Cid()) + return api.Dag().Get(ctx, rp.RootCid()) } diff --git a/client/rpc/unixfs.go b/client/rpc/unixfs.go index 39e3f72013d..077d3f5a64f 100644 --- a/client/rpc/unixfs.go +++ b/client/rpc/unixfs.go @@ -105,7 +105,7 @@ loop: return nil, err } - ifevt.Path = path.NewIPFSPath(c) + ifevt.Path = path.FromCid(c) } select { @@ -121,7 +121,7 @@ loop: return nil, err } - return path.NewIPFSPath(c), nil + return path.FromCid(c), nil } type lsLink struct { diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index 895236d9ecc..6d03b12c906 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -262,5 +262,5 @@ func initializeIpnsKeyspace(repoRoot string) error { return err } - return nd.Namesys.Publish(ctx, nd.PrivateKey, path.NewIPFSPath(emptyDir.Cid())) + return nd.Namesys.Publish(ctx, nd.PrivateKey, path.FromCid(emptyDir.Cid())) } diff --git a/core/commands/add.go b/core/commands/add.go index fa78d70746b..eb855fe932c 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -317,7 +317,7 @@ See 'dag export' and 'dag import' for more information. } var nodeAdded ipld.Node - nodeAdded, err = api.Dag().Get(req.Context, pathAdded.Cid()) + nodeAdded, err = api.Dag().Get(req.Context, pathAdded.RootCid()) if err != nil { errCh <- err return @@ -340,7 +340,7 @@ See 'dag export' and 'dag import' for more information. h := "" if output.Path != nil { - h = enc.Encode(output.Path.Cid()) + h = enc.Encode(output.Path.RootCid()) } if !dir && addit.Name() != "" { diff --git a/core/commands/block.go b/core/commands/block.go index b5077aa9ca8..103addcafaf 100644 --- a/core/commands/block.go +++ b/core/commands/block.go @@ -77,7 +77,7 @@ on raw IPFS blocks. It outputs the following to stdout: } return cmds.EmitOnce(res, &BlockStat{ - Key: b.Path().Cid().String(), + Key: b.Path().RootCid().String(), Size: b.Size(), }) }, @@ -210,7 +210,7 @@ only for backward compatibility when a legacy CIDv0 is required (--format=v0). } err = res.Emit(&BlockStat{ - Key: p.Path().Cid().String(), + Key: p.Path().RootCid().String(), Size: p.Size(), }) if err != nil { @@ -278,7 +278,7 @@ It takes a list of CIDs to remove from the local datastore.. err = api.Block().Rm(req.Context, rp, options.Block.Force(force)) if err != nil { if err := res.Emit(&removedBlock{ - Hash: rp.Cid().String(), + Hash: rp.RootCid().String(), Error: err.Error(), }); err != nil { return err @@ -288,7 +288,7 @@ It takes a list of CIDs to remove from the local datastore.. if !quiet { err := res.Emit(&removedBlock{ - Hash: rp.Cid().String(), + Hash: rp.RootCid().String(), }) if err != nil { return err diff --git a/core/commands/dag/get.go b/core/commands/dag/get.go index 3add3f6b6fb..d15d2b69ecb 100644 --- a/core/commands/dag/get.go +++ b/core/commands/dag/get.go @@ -39,7 +39,7 @@ func dagGet(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) e return err } - obj, err := api.Dag().Get(req.Context, rp.Cid()) + obj, err := api.Dag().Get(req.Context, rp.RootCid()) if err != nil { return err } diff --git a/core/commands/dag/resolve.go b/core/commands/dag/resolve.go index 8d5c9be7135..f8a4b36cd4b 100644 --- a/core/commands/dag/resolve.go +++ b/core/commands/dag/resolve.go @@ -25,7 +25,7 @@ func dagResolve(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environmen } return cmds.EmitOnce(res, &ResolveOutput{ - Cid: rp.Cid(), + Cid: rp.RootCid(), RemPath: path.SegmentsToString(remainder...), }) } diff --git a/core/commands/dag/stat.go b/core/commands/dag/stat.go index 9e0b2747416..bb9be7e0d90 100644 --- a/core/commands/dag/stat.go +++ b/core/commands/dag/stat.go @@ -41,11 +41,11 @@ func dagStat(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) return fmt.Errorf("cannot return size for anything other than a DAG with a root CID") } - obj, err := nodeGetter.Get(req.Context, rp.Cid()) + obj, err := nodeGetter.Get(req.Context, rp.RootCid()) if err != nil { return err } - dagstats := &DagStat{Cid: rp.Cid()} + dagstats := &DagStat{Cid: rp.RootCid()} dagStatSummary.appendStats(dagstats) err = traverse.Traverse(obj, traverse.Options{ DAG: nodeGetter, diff --git a/core/commands/object/diff.go b/core/commands/object/diff.go index aa1e91c83bd..882fb63e1a1 100644 --- a/core/commands/object/diff.go +++ b/core/commands/object/diff.go @@ -83,11 +83,11 @@ Example: } if change.Before != nil { - out[i].Before = change.Before.Cid() + out[i].Before = change.Before.RootCid() } if change.After != nil { - out[i].After = change.After.Cid() + out[i].After = change.After.RootCid() } } diff --git a/core/commands/object/object.go b/core/commands/object/object.go index 28a37aaf9f4..8024edfe399 100644 --- a/core/commands/object/object.go +++ b/core/commands/object/object.go @@ -163,7 +163,7 @@ multihash. Provided for legacy reasons. Use 'ipfs dag get' instead. } out := &Object{ - Hash: enc.Encode(rp.Cid()), + Hash: enc.Encode(rp.RootCid()), Links: outLinks, } @@ -448,7 +448,7 @@ DEPRECATED and provided for legacy reasons. Use 'ipfs dag put' instead. return err } - return cmds.EmitOnce(res, &Object{Hash: enc.Encode(p.Cid())}) + return cmds.EmitOnce(res, &Object{Hash: enc.Encode(p.RootCid())}) }, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *Object) error { diff --git a/core/commands/object/patch.go b/core/commands/object/patch.go index 830b803622a..7e440b1af21 100644 --- a/core/commands/object/patch.go +++ b/core/commands/object/patch.go @@ -90,11 +90,11 @@ DEPRECATED and provided for legacy reasons. Use 'ipfs add' or 'ipfs files' inste return err } - if err := cmdutils.CheckCIDSize(req, p.Cid(), api.Dag()); err != nil { + if err := cmdutils.CheckCIDSize(req, p.RootCid(), api.Dag()); err != nil { return err } - return cmds.EmitOnce(res, &Object{Hash: p.Cid().String()}) + return cmds.EmitOnce(res, &Object{Hash: p.RootCid().String()}) }, Type: &Object{}, Encoders: cmds.EncoderMap{ @@ -144,11 +144,11 @@ DEPRECATED and provided for legacy reasons. Use 'files cp' and 'dag put' instead return err } - if err := cmdutils.CheckCIDSize(req, p.Cid(), api.Dag()); err != nil { + if err := cmdutils.CheckCIDSize(req, p.RootCid(), api.Dag()); err != nil { return err } - return cmds.EmitOnce(res, &Object{Hash: p.Cid().String()}) + return cmds.EmitOnce(res, &Object{Hash: p.RootCid().String()}) }, Type: Object{}, Encoders: cmds.EncoderMap{ @@ -190,11 +190,11 @@ DEPRECATED and provided for legacy reasons. Use 'files rm' instead. return err } - if err := cmdutils.CheckCIDSize(req, p.Cid(), api.Dag()); err != nil { + if err := cmdutils.CheckCIDSize(req, p.RootCid(), api.Dag()); err != nil { return err } - return cmds.EmitOnce(res, &Object{Hash: p.Cid().String()}) + return cmds.EmitOnce(res, &Object{Hash: p.RootCid().String()}) }, Type: Object{}, Encoders: cmds.EncoderMap{ @@ -269,11 +269,11 @@ Use MFS and 'files' commands instead: return err } - if err := cmdutils.CheckCIDSize(req, p.Cid(), api.Dag()); err != nil { + if err := cmdutils.CheckCIDSize(req, p.RootCid(), api.Dag()); err != nil { return err } - return cmds.EmitOnce(res, &Object{Hash: p.Cid().String()}) + return cmds.EmitOnce(res, &Object{Hash: p.RootCid().String()}) }, Type: Object{}, Encoders: cmds.EncoderMap{ diff --git a/core/commands/pin/pin.go b/core/commands/pin/pin.go index 8696584ade5..aa4470d700b 100644 --- a/core/commands/pin/pin.go +++ b/core/commands/pin/pin.go @@ -197,7 +197,7 @@ func pinAddMany(ctx context.Context, api coreiface.CoreAPI, enc cidenc.Encoder, if err := api.Pin().Add(ctx, rp, options.Pin.Recursive(recursive)); err != nil { return nil, err } - added[i] = enc.Encode(rp.Cid()) + added[i] = enc.Encode(rp.RootCid()) } return added, nil @@ -257,7 +257,7 @@ ipfs pin ls -t indirect return err } - id := enc.Encode(rp.Cid()) + id := enc.Encode(rp.RootCid()) pins = append(pins, id) if err := api.Pin().Rm(req.Context, rp, options.Pin.RmRecursive(recursive)); err != nil { return err @@ -491,7 +491,7 @@ func pinLsKeys(req *cmds.Request, typeStr string, api coreiface.CoreAPI, emit fu err = emit(PinLsOutputWrapper{ PinLsObject: PinLsObject{ Type: pinType, - Cid: enc.Encode(rp.Cid()), + Cid: enc.Encode(rp.RootCid()), }, }) if err != nil { @@ -532,7 +532,7 @@ func pinLsAll(req *cmds.Request, typeStr string, api coreiface.CoreAPI, emit fun err = emit(PinLsOutputWrapper{ PinLsObject: PinLsObject{ Type: p.Type(), - Cid: enc.Encode(p.Path().Cid()), + Cid: enc.Encode(p.Path().RootCid()), }, }) if err != nil { @@ -608,7 +608,7 @@ pin. return err } - return cmds.EmitOnce(res, &PinOutput{Pins: []string{enc.Encode(from.Cid()), enc.Encode(to.Cid())}}) + return cmds.EmitOnce(res, &PinOutput{Pins: []string{enc.Encode(from.RootCid()), enc.Encode(to.RootCid())}}) }, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *PinOutput) error { diff --git a/core/commands/pin/remotepin.go b/core/commands/pin/remotepin.go index 59c064e6c6f..132532554cc 100644 --- a/core/commands/pin/remotepin.go +++ b/core/commands/pin/remotepin.go @@ -182,7 +182,7 @@ NOTE: a comma-separated notation is supported in CLI for convenience: return err } - isInBlockstore, err := node.Blockstore.Has(req.Context, rp.Cid()) + isInBlockstore, err := node.Blockstore.Has(req.Context, rp.RootCid()) if err != nil { return err } @@ -199,7 +199,7 @@ NOTE: a comma-separated notation is supported in CLI for convenience: // Execute remote pin request // TODO: fix panic when pinning service is down - ps, err := c.Add(ctx, rp.Cid(), opts...) + ps, err := c.Add(ctx, rp.RootCid(), opts...) if err != nil { return err } diff --git a/core/commands/refs.go b/core/commands/refs.go index 99da47fd46c..3c58fe96113 100644 --- a/core/commands/refs.go +++ b/core/commands/refs.go @@ -179,7 +179,7 @@ func objectsForPaths(ctx context.Context, n iface.CoreAPI, paths []string) ([]ci if err != nil { return nil, err } - roots[i] = o.Cid() + roots[i] = o.RootCid() } return roots, nil } diff --git a/core/commands/resolve.go b/core/commands/resolve.go index a69b21564ba..5db392bf211 100644 --- a/core/commands/resolve.go +++ b/core/commands/resolve.go @@ -140,7 +140,7 @@ Resolve the value of an IPFS DAG path: } // Trick to encode path with correct encoding. - encodedPath := "/" + rp.Namespace().String() + "/" + enc.Encode(rp.Cid()) + encodedPath := "/" + rp.Namespace() + "/" + enc.Encode(rp.RootCid()) if len(remainder) != 0 { encodedPath += path.SegmentsToString(remainder...) } diff --git a/core/commands/urlstore.go b/core/commands/urlstore.go index 4eec85ede4a..e5dd1ce4d53 100644 --- a/core/commands/urlstore.go +++ b/core/commands/urlstore.go @@ -92,7 +92,7 @@ settings for 'ipfs add'. } size, _ := file.Size() return cmds.EmitOnce(res, &BlockStat{ - Key: enc.Encode(path.Cid()), + Key: enc.Encode(path.RootCid()), Size: int(size), }) }, diff --git a/core/coreapi/block.go b/core/coreapi/block.go index 4da01224f05..08743c16e08 100644 --- a/core/coreapi/block.go +++ b/core/coreapi/block.go @@ -79,7 +79,7 @@ func (api *BlockAPI) Get(ctx context.Context, p path.Path) (io.Reader, error) { return nil, err } - b, err := api.blocks.GetBlock(ctx, rp.Cid()) + b, err := api.blocks.GetBlock(ctx, rp.RootCid()) if err != nil { return nil, err } @@ -100,7 +100,7 @@ func (api *BlockAPI) Rm(ctx context.Context, p path.Path, opts ...caopts.BlockRm if err != nil { return err } - cids := []cid.Cid{rp.Cid()} + cids := []cid.Cid{rp.RootCid()} o := util.RmBlocksOpts{Force: settings.Force} out, err := util.RmBlocks(ctx, api.blockstore, api.pinning, cids, o) @@ -137,7 +137,7 @@ func (api *BlockAPI) Stat(ctx context.Context, p path.Path) (coreiface.BlockStat return nil, err } - b, err := api.blocks.GetBlock(ctx, rp.Cid()) + b, err := api.blocks.GetBlock(ctx, rp.RootCid()) if err != nil { return nil, err } diff --git a/core/coreapi/dht.go b/core/coreapi/dht.go index 78a95b6c48f..c960ee0844c 100644 --- a/core/coreapi/dht.go +++ b/core/coreapi/dht.go @@ -63,7 +63,7 @@ func (api *DhtAPI) FindProviders(ctx context.Context, p path.Path, opts ...caopt return nil, fmt.Errorf("number of providers must be greater than 0") } - pchan := api.routing.FindProvidersAsync(ctx, rp.Cid(), numProviders) + pchan := api.routing.FindProvidersAsync(ctx, rp.RootCid(), numProviders) return pchan, nil } @@ -87,7 +87,7 @@ func (api *DhtAPI) Provide(ctx context.Context, path path.Path, opts ...caopts.D return err } - c := rp.Cid() + c := rp.RootCid() has, err := api.blockstore.Has(ctx, c) if err != nil { diff --git a/core/coreapi/object.go b/core/coreapi/object.go index 0b9550255e6..b5da0d7686d 100644 --- a/core/coreapi/object.go +++ b/core/coreapi/object.go @@ -143,7 +143,7 @@ func (api *ObjectAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.Obj } } - return path.NewIPFSPath(dagnode.Cid()), nil + return path.FromCid(dagnode.Cid()), nil } func (api *ObjectAPI) Get(ctx context.Context, path path.Path) (ipld.Node, error) { @@ -259,7 +259,7 @@ func (api *ObjectAPI) AddLink(ctx context.Context, base path.Path, name string, return nil, err } - return path.NewIPFSPath(nnode.Cid()), nil + return path.FromCid(nnode.Cid()), nil } func (api *ObjectAPI) RmLink(ctx context.Context, base path.Path, link string) (path.ImmutablePath, error) { @@ -291,7 +291,7 @@ func (api *ObjectAPI) RmLink(ctx context.Context, base path.Path, link string) ( return nil, err } - return path.NewIPFSPath(nnode.Cid()), nil + return path.FromCid(nnode.Cid()), nil } func (api *ObjectAPI) AppendData(ctx context.Context, path path.Path, r io.Reader) (path.ImmutablePath, error) { @@ -334,7 +334,7 @@ func (api *ObjectAPI) patchData(ctx context.Context, p path.Path, r io.Reader, a return nil, err } - return path.NewIPFSPath(pbnd.Cid()), nil + return path.FromCid(pbnd.Cid()), nil } func (api *ObjectAPI) Diff(ctx context.Context, before path.Path, after path.Path) ([]coreiface.ObjectChange, error) { @@ -367,11 +367,11 @@ func (api *ObjectAPI) Diff(ctx context.Context, before path.Path, after path.Pat } if change.Before.Defined() { - out[i].Before = path.NewIPFSPath(change.Before) + out[i].Before = path.FromCid(change.Before) } if change.After.Defined() { - out[i].After = path.NewIPFSPath(change.After) + out[i].After = path.FromCid(change.After) } } diff --git a/core/coreapi/path.go b/core/coreapi/path.go index bbc6ea2d209..2e1ca28df49 100644 --- a/core/coreapi/path.go +++ b/core/coreapi/path.go @@ -27,7 +27,7 @@ func (api *CoreAPI) ResolveNode(ctx context.Context, p path.Path) (ipld.Node, er return nil, err } - node, err := api.dag.Get(ctx, rp.Cid()) + node, err := api.dag.Get(ctx, rp.RootCid()) if err != nil { return nil, err } @@ -54,7 +54,7 @@ func (api *CoreAPI) ResolvePath(ctx context.Context, p path.Path) (path.Immutabl case path.IPFSNamespace: resolver = api.unixFSPathResolver default: - return nil, nil, fmt.Errorf("unsupported path namespace: %s", p.Namespace().String()) + return nil, nil, fmt.Errorf("unsupported path namespace: %s", p.Namespace()) } imPath, err := path.NewImmutablePath(p) @@ -67,7 +67,7 @@ func (api *CoreAPI) ResolvePath(ctx context.Context, p path.Path) (path.Immutabl return nil, nil, err } - segments := []string{p.Namespace().String(), node.String()} + segments := []string{p.Namespace(), node.String()} segments = append(segments, remainder...) p, err = path.NewPathFromSegments(segments...) diff --git a/core/coreapi/pin.go b/core/coreapi/pin.go index d087a8252a4..47ea1975168 100644 --- a/core/coreapi/pin.go +++ b/core/coreapi/pin.go @@ -91,7 +91,7 @@ func (api *PinAPI) IsPinned(ctx context.Context, p path.Path, opts ...caopts.Pin return "", false, fmt.Errorf("invalid type '%s', must be one of {direct, indirect, recursive, all}", settings.WithType) } - return api.pinning.IsPinnedWithType(ctx, resolved.Cid(), mode) + return api.pinning.IsPinnedWithType(ctx, resolved.RootCid(), mode) } // Rm pin rm api @@ -115,7 +115,7 @@ func (api *PinAPI) Rm(ctx context.Context, p path.Path, opts ...caopts.PinRmOpti // to take a lock to prevent a concurrent garbage collection defer api.blockstore.PinLock(ctx).Unlock(ctx) - if err = api.pinning.Unpin(ctx, rp.Cid(), settings.Recursive); err != nil { + if err = api.pinning.Unpin(ctx, rp.RootCid(), settings.Recursive); err != nil { return err } @@ -148,7 +148,7 @@ func (api *PinAPI) Update(ctx context.Context, from path.Path, to path.Path, opt defer api.blockstore.PinLock(ctx).Unlock(ctx) - err = api.pinning.Update(ctx, fp.Cid(), tp.Cid(), settings.Unpin) + err = api.pinning.Update(ctx, fp.RootCid(), tp.RootCid(), settings.Unpin) if err != nil { return err } diff --git a/core/coreapi/test/path_test.go b/core/coreapi/test/path_test.go index cbfddd538cb..6ba80423d35 100644 --- a/core/coreapi/test/path_test.go +++ b/core/coreapi/test/path_test.go @@ -45,7 +45,7 @@ func TestPathUnixFSHAMTPartial(t *testing.T) { } // Get the root of the directory - nd, err := a.Dag().Get(ctx, r.Cid()) + nd, err := a.Dag().Get(ctx, r.RootCid()) if err != nil { t.Fatal(err) } @@ -55,7 +55,7 @@ func TestPathUnixFSHAMTPartial(t *testing.T) { pbNode := nd.(*merkledag.ProtoNode) // Remove one of the sharded directory blocks - if err := a.Block().Rm(ctx, path.NewIPFSPath(pbNode.Links()[0].Cid)); err != nil { + if err := a.Block().Rm(ctx, path.FromCid(pbNode.Links()[0].Cid)); err != nil { t.Fatal(err) } diff --git a/core/coreapi/unixfs.go b/core/coreapi/unixfs.go index 778fef5c1b6..3c0d6042a94 100644 --- a/core/coreapi/unixfs.go +++ b/core/coreapi/unixfs.go @@ -201,7 +201,7 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options } } - return path.NewIPFSPath(nd.Cid()), nil + return path.FromCid(nd.Cid()), nil } func (api *UnixfsAPI) Get(ctx context.Context, p path.Path) (files.Node, error) { diff --git a/core/coreunix/add.go b/core/coreunix/add.go index 3a2b91c4bab..123c9fe652b 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -506,7 +506,7 @@ func getOutput(dagnode ipld.Node) (*coreiface.AddEvent, error) { } output := &coreiface.AddEvent{ - Path: path.NewIPFSPath(c), + Path: path.FromCid(c), Size: strconv.FormatUint(s, 10), } diff --git a/core/coreunix/add_test.go b/core/coreunix/add_test.go index be6f98ed7db..a09fd5d2bc9 100644 --- a/core/coreunix/add_test.go +++ b/core/coreunix/add_test.go @@ -133,7 +133,7 @@ func TestAddMultipleGCLive(t *testing.T) { } for o := range out { - if _, ok := removedHashes[o.(*coreiface.AddEvent).Path.Cid().String()]; ok { + if _, ok := removedHashes[o.(*coreiface.AddEvent).Path.RootCid().String()]; ok { t.Fatal("gc'ed a hash we just added") } } @@ -187,7 +187,7 @@ func TestAddGCLive(t *testing.T) { addedHashes := make(map[string]struct{}) select { case o := <-out: - addedHashes[o.(*coreiface.AddEvent).Path.Cid().String()] = struct{}{} + addedHashes[o.(*coreiface.AddEvent).Path.RootCid().String()] = struct{}{} case <-addDone: t.Fatal("add shouldn't complete yet") } @@ -217,7 +217,7 @@ func TestAddGCLive(t *testing.T) { // receive next object from adder o := <-out - addedHashes[o.(*coreiface.AddEvent).Path.Cid().String()] = struct{}{} + addedHashes[o.(*coreiface.AddEvent).Path.RootCid().String()] = struct{}{} <-gcstarted @@ -233,7 +233,7 @@ func TestAddGCLive(t *testing.T) { var last cid.Cid for a := range out { // wait for it to finish - c, err := cid.Decode(a.(*coreiface.AddEvent).Path.Cid().String()) + c, err := cid.Decode(a.(*coreiface.AddEvent).Path.RootCid().String()) if err != nil { t.Fatal(err) } diff --git a/docs/examples/kubo-as-a-library/go.mod b/docs/examples/kubo-as-a-library/go.mod index ebb483a562a..450c963fd50 100644 --- a/docs/examples/kubo-as-a-library/go.mod +++ b/docs/examples/kubo-as-a-library/go.mod @@ -7,7 +7,7 @@ go 1.20 replace github.com/ipfs/kubo => ./../../.. require ( - github.com/ipfs/boxo v0.13.2-0.20231005104529-f0e9c2ff4fd4 + github.com/ipfs/boxo v0.13.2-0.20231005175232-77b6c456e06d github.com/ipfs/kubo v0.0.0-00010101000000-000000000000 github.com/libp2p/go-libp2p v0.31.0 github.com/multiformats/go-multiaddr v0.11.0 diff --git a/docs/examples/kubo-as-a-library/go.sum b/docs/examples/kubo-as-a-library/go.sum index 49925064ebd..e51a7a87653 100644 --- a/docs/examples/kubo-as-a-library/go.sum +++ b/docs/examples/kubo-as-a-library/go.sum @@ -300,8 +300,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.13.2-0.20231005104529-f0e9c2ff4fd4 h1:DHAxtZ9mY1ukgzap2vRamUo6MjYrJr2PuvRZqSeEOTo= -github.com/ipfs/boxo v0.13.2-0.20231005104529-f0e9c2ff4fd4/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= +github.com/ipfs/boxo v0.13.2-0.20231005175232-77b6c456e06d h1:DS/o1IqiP5rqdBY6YhLOLrxsMJ7XWel++E3w5t/4Lao= +github.com/ipfs/boxo v0.13.2-0.20231005175232-77b6c456e06d/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU= github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY= diff --git a/docs/examples/kubo-as-a-library/main.go b/docs/examples/kubo-as-a-library/main.go index aed916982fa..b7764a20651 100644 --- a/docs/examples/kubo-as-a-library/main.go +++ b/docs/examples/kubo-as-a-library/main.go @@ -320,11 +320,11 @@ func main() { } }() - exampleCIDStr := peerCidFile.Cid().String() + exampleCIDStr := peerCidFile.RootCid().String() fmt.Printf("Fetching a file from the network with CID %s\n", exampleCIDStr) outputPath := outputBasePath + exampleCIDStr - testCID := path.NewIPFSPath(peerCidFile.Cid()) + testCID := path.FromCid(peerCidFile.RootCid()) rootNode, err := ipfsB.Unixfs().Get(ctx, testCID) if err != nil { diff --git a/fuse/ipns/common.go b/fuse/ipns/common.go index ad8ff8a6b6d..69924738e22 100644 --- a/fuse/ipns/common.go +++ b/fuse/ipns/common.go @@ -30,5 +30,5 @@ func InitializeKeyspace(n *core.IpfsNode, key ci.PrivKey) error { pub := nsys.NewIpnsPublisher(n.Routing, n.Repo.Datastore()) - return pub.Publish(ctx, key, path.NewIPFSPath(emptyDir.Cid())) + return pub.Publish(ctx, key, path.FromCid(emptyDir.Cid())) } diff --git a/fuse/ipns/ipns_unix.go b/fuse/ipns/ipns_unix.go index 3506cfd5a4b..77cb8b18f78 100644 --- a/fuse/ipns/ipns_unix.go +++ b/fuse/ipns/ipns_unix.go @@ -86,7 +86,7 @@ type Root struct { func ipnsPubFunc(ipfs iface.CoreAPI, key iface.Key) mfs.PubFunc { return func(ctx context.Context, c cid.Cid) error { - _, err := ipfs.Name().Publish(ctx, path.NewIPFSPath(c), options.Name.Key(key.Name())) + _, err := ipfs.Name().Publish(ctx, path.FromCid(c), options.Name.Key(key.Name())) return err } } diff --git a/fuse/readonly/ipfs_test.go b/fuse/readonly/ipfs_test.go index 76f7a3cdfbb..385ae1272c5 100644 --- a/fuse/readonly/ipfs_test.go +++ b/fuse/readonly/ipfs_test.go @@ -190,7 +190,7 @@ func TestIpfsStressRead(t *testing.T) { continue } - relpath := strings.Replace(item.String(), item.Namespace().String(), "", 1) + relpath := strings.Replace(item.String(), item.Namespace(), "", 1) fname := gopath.Join(mnt.Dir, relpath) rbuf, err := os.ReadFile(fname) diff --git a/go.mod b/go.mod index d5f7a1d1993..3a45875a268 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/fsnotify/fsnotify v1.6.0 github.com/google/uuid v1.3.1 github.com/hashicorp/go-multierror v1.1.1 - github.com/ipfs/boxo v0.13.2-0.20231005104529-f0e9c2ff4fd4 + github.com/ipfs/boxo v0.13.2-0.20231005175232-77b6c456e06d github.com/ipfs/go-block-format v0.2.0 github.com/ipfs/go-cid v0.4.1 github.com/ipfs/go-cidutil v0.1.0 diff --git a/go.sum b/go.sum index 4a57a905f40..f3192944a50 100644 --- a/go.sum +++ b/go.sum @@ -335,8 +335,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.13.2-0.20231005104529-f0e9c2ff4fd4 h1:DHAxtZ9mY1ukgzap2vRamUo6MjYrJr2PuvRZqSeEOTo= -github.com/ipfs/boxo v0.13.2-0.20231005104529-f0e9c2ff4fd4/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= +github.com/ipfs/boxo v0.13.2-0.20231005175232-77b6c456e06d h1:DS/o1IqiP5rqdBY6YhLOLrxsMJ7XWel++E3w5t/4Lao= +github.com/ipfs/boxo v0.13.2-0.20231005175232-77b6c456e06d/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU= github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ= diff --git a/test/dependencies/go.mod b/test/dependencies/go.mod index 52e6b432ada..192c74d3d79 100644 --- a/test/dependencies/go.mod +++ b/test/dependencies/go.mod @@ -7,7 +7,7 @@ replace github.com/ipfs/kubo => ../../ require ( github.com/Kubuxu/gocovmerge v0.0.0-20161216165753-7ecaa51963cd github.com/golangci/golangci-lint v1.54.1 - github.com/ipfs/boxo v0.13.2-0.20231005104529-f0e9c2ff4fd4 + github.com/ipfs/boxo v0.13.2-0.20231005175232-77b6c456e06d github.com/ipfs/go-cid v0.4.1 github.com/ipfs/go-cidutil v0.1.0 github.com/ipfs/go-datastore v0.6.0 diff --git a/test/dependencies/go.sum b/test/dependencies/go.sum index 5ff8aa8de72..ee1f69e0bed 100644 --- a/test/dependencies/go.sum +++ b/test/dependencies/go.sum @@ -396,8 +396,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.13.2-0.20231005104529-f0e9c2ff4fd4 h1:DHAxtZ9mY1ukgzap2vRamUo6MjYrJr2PuvRZqSeEOTo= -github.com/ipfs/boxo v0.13.2-0.20231005104529-f0e9c2ff4fd4/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= +github.com/ipfs/boxo v0.13.2-0.20231005175232-77b6c456e06d h1:DS/o1IqiP5rqdBY6YhLOLrxsMJ7XWel++E3w5t/4Lao= +github.com/ipfs/boxo v0.13.2-0.20231005175232-77b6c456e06d/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU= github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNiW1Ycs=