Commit 5b015d97 authored by Kevin Atkinson's avatar Kevin Atkinson

gx update and fix code to use new Cid type

parent c9cfadd2
......@@ -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",
......
......@@ -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())
}
......@@ -160,7 +160,7 @@ 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:]
......@@ -168,13 +168,13 @@ func SplitAbsPath(fpath Path) (*cid.Cid, []string, error) {
// 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
......
......@@ -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
......@@ -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 {
......@@ -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 {
......@@ -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
......@@ -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
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment