Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .gx/lastpubver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.14: QmNgXoHgXU1HzNb2HEZmRww9fDKE9NfDsvQwWLHiKHpvKM
1.1.0: QmRYx6fJzTWFoeTo3qQn64iDrVC154Gy9waQDhvKRr2ND3
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
"gxDependencies": [
{
"author": "why",
"hash": "QmNr4E8z9bGTztvHJktp7uQaMdx9p3r9Asrq6eYk7iCh4a",
"hash": "QmURqt1jB9Yu3X4Tr9WQJf36QGN7vi8mGTzjnX2ij1CJwC",
"name": "go-merkledag",
"version": "1.0.14"
"version": "1.1.0"
},
{
"author": "whyrusleeping",
"hash": "QmX5CsuHyVZeTLxgRSYkgLSDQKb9UjE8xnhQzCEJWWWFsC",
"hash": "QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL",
"name": "go-ipld-format",
"version": "0.5.8"
"version": "0.6.0"
},
{
"author": "whyrusleeping",
"hash": "QmZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb",
"hash": "QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7",
"name": "go-cid",
"version": "0.8.0"
"version": "0.9.0"
},
{
"hash": "QmRREK2CAZ5Re2Bd9zZFG6FeYDppUWt5cMgsoUEp3ktgSr",
Expand All @@ -36,6 +36,6 @@
"license": "",
"name": "go-path",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "1.0.14"
"version": "1.1.0"
}

8 changes: 4 additions & 4 deletions path.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func FromString(s string) Path {
}

// FromCid safely converts a cid.Cid type to a Path type.
func FromCid(c *cid.Cid) Path {
func FromCid(c cid.Cid) Path {
return Path("/ipfs/" + c.String())
}

Expand Down Expand Up @@ -160,21 +160,21 @@ func SplitList(pth string) []string {

// SplitAbsPath clean up and split fpath. It extracts the first component (which
// must be a Multihash) and return it separately.
func SplitAbsPath(fpath Path) (*cid.Cid, []string, error) {
func SplitAbsPath(fpath Path) (cid.Cid, []string, error) {
parts := fpath.Segments()
if parts[0] == "ipfs" || parts[0] == "ipld" {
parts = parts[1:]
}

// if nothing, bail.
if len(parts) == 0 {
return nil, nil, ErrNoComponents
return cid.Cid{}, nil, ErrNoComponents
}

c, err := cid.Decode(parts[0])
// first element in the path is a cid
if err != nil {
return nil, nil, err
return cid.Cid{}, nil, err
}

return c, parts[1:], nil
Expand Down
18 changes: 9 additions & 9 deletions resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var ErrNoComponents = errors.New(
// ErrNoLink is returned when a link is not found in a path
type ErrNoLink struct {
Name string
Node *cid.Cid
Node cid.Cid
}

// Error implements the Error interface for ErrNoLink with a useful
Expand Down Expand Up @@ -57,10 +57,10 @@ func NewBasicResolver(ds ipld.DAGService) *Resolver {

// ResolveToLastNode walks the given path and returns the cid of the last node
// referenced by the path
func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (*cid.Cid, []string, error) {
func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (cid.Cid, []string, error) {
c, p, err := path.SplitAbsPath(fpath)
if err != nil {
return nil, nil, err
return cid.Cid{}, nil, err
}

if len(p) == 0 {
Expand All @@ -69,7 +69,7 @@ func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (*cid

nd, err := r.DAG.Get(ctx, c)
if err != nil {
return nil, nil, err
return cid.Cid{}, nil, err
}

for len(p) > 0 {
Expand All @@ -83,12 +83,12 @@ func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (*cid
}

if err != nil {
return nil, nil, err
return cid.Cid{}, nil, err
}

next, err := lnk.GetNode(ctx, r.DAG)
if err != nil {
return nil, nil, err
return cid.Cid{}, nil, err
}
nd = next
p = rest
Expand All @@ -101,15 +101,15 @@ func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (*cid
// Confirm the path exists within the object
val, rest, err := nd.Resolve(p)
if err != nil {
return nil, nil, err
return cid.Cid{}, nil, err
}

if len(rest) > 0 {
return nil, nil, errors.New("path failed to resolve fully")
return cid.Cid{}, nil, errors.New("path failed to resolve fully")
}
switch val.(type) {
case *ipld.Link:
return nil, nil, errors.New("inconsistent ResolveOnce / nd.Resolve")
return cid.Cid{}, nil, errors.New("inconsistent ResolveOnce / nd.Resolve")
default:
return nd.Cid(), p, nil
}
Expand Down