Commit 57dc363b authored by Kevin Atkinson's avatar Kevin Atkinson

gx update and fix code to use new Cid type

parent 1b70c30f
......@@ -18,7 +18,7 @@ func newTestDag() *testDag {
return &testDag{nodes: make(map[string]Node)}
}
func (d *testDag) Get(ctx context.Context, cid *cid.Cid) (Node, error) {
func (d *testDag) Get(ctx context.Context, cid cid.Cid) (Node, error) {
d.mu.Lock()
defer d.mu.Unlock()
if n, ok := d.nodes[cid.KeyString()]; ok {
......@@ -27,7 +27,7 @@ func (d *testDag) Get(ctx context.Context, cid *cid.Cid) (Node, error) {
return nil, ErrNotFound
}
func (d *testDag) GetMany(ctx context.Context, cids []*cid.Cid) <-chan *NodeOption {
func (d *testDag) GetMany(ctx context.Context, cids []cid.Cid) <-chan *NodeOption {
d.mu.Lock()
defer d.mu.Unlock()
out := make(chan *NodeOption, len(cids))
......@@ -58,14 +58,14 @@ func (d *testDag) AddMany(ctx context.Context, nodes []Node) error {
return nil
}
func (d *testDag) Remove(ctx context.Context, c *cid.Cid) error {
func (d *testDag) Remove(ctx context.Context, c cid.Cid) error {
d.mu.Lock()
defer d.mu.Unlock()
delete(d.nodes, c.KeyString())
return nil
}
func (d *testDag) RemoveMany(ctx context.Context, cids []*cid.Cid) error {
func (d *testDag) RemoveMany(ctx context.Context, cids []cid.Cid) error {
d.mu.Lock()
defer d.mu.Unlock()
for _, c := range cids {
......
......@@ -9,7 +9,7 @@ import (
// GetLinks returns the CIDs of the children of the given node. Prefer this
// method over looking up the node itself and calling `Links()` on it as this
// method may be able to use a link cache.
func GetLinks(ctx context.Context, ng NodeGetter, c *cid.Cid) ([]*Link, error) {
func GetLinks(ctx context.Context, ng NodeGetter, c cid.Cid) ([]*Link, error) {
if c.Type() == cid.Raw {
return nil, nil
}
......@@ -27,7 +27,7 @@ func GetLinks(ctx context.Context, ng NodeGetter, c *cid.Cid) ([]*Link, error) {
// It returns an array of NodePromise with the linked nodes all in the proper
// order.
func GetDAG(ctx context.Context, ds NodeGetter, root Node) []*NodePromise {
var cids []*cid.Cid
var cids []cid.Cid
for _, lnk := range root.Links() {
cids = append(cids, lnk.Cid)
}
......@@ -37,7 +37,7 @@ func GetDAG(ctx context.Context, ds NodeGetter, root Node) []*NodePromise {
// GetNodes returns an array of 'FutureNode' promises, with each corresponding
// to the key with the same index as the passed in keys
func GetNodes(ctx context.Context, ds NodeGetter, keys []*cid.Cid) []*NodePromise {
func GetNodes(ctx context.Context, ds NodeGetter, keys []cid.Cid) []*NodePromise {
// Early out if no work to do
if len(keys) == 0 {
......@@ -89,7 +89,7 @@ func GetNodes(ctx context.Context, ds NodeGetter, keys []*cid.Cid) []*NodePromis
return promises
}
func Copy(ctx context.Context, from, to DAGService, root *cid.Cid) error {
func Copy(ctx context.Context, from, to DAGService, root cid.Cid) error {
node, err := from.Get(ctx, root)
if err != nil {
return err
......@@ -109,7 +109,7 @@ func Copy(ctx context.Context, from, to DAGService, root *cid.Cid) error {
}
// Remove duplicates from a list of keys
func dedupeKeys(cids []*cid.Cid) []*cid.Cid {
func dedupeKeys(cids []cid.Cid) []cid.Cid {
set := cid.NewSet()
for _, c := range cids {
set.Add(c)
......
......@@ -43,10 +43,10 @@ func (n *TestNode) Copy() Node {
return &EmptyNode{}
}
func (n *TestNode) Cid() *cid.Cid {
func (n *TestNode) Cid() cid.Cid {
c, err := n.builder.Sum(n.RawData())
if err != nil {
return nil
return cid.Cid{}
}
return c
}
......
......@@ -53,7 +53,7 @@ type Link struct {
Size uint64
// multihash of the target object
Cid *cid.Cid
Cid cid.Cid
}
// NodeStat is a statistics object for a Node. Mostly sizes.
......
......@@ -28,7 +28,7 @@ func (n *EmptyNode) Copy() Node {
return &EmptyNode{}
}
func (n *EmptyNode) Cid() *cid.Cid {
func (n *EmptyNode) Cid() cid.Cid {
id, err := cid.Prefix{
Version: 1,
Codec: cid.Raw,
......
......@@ -20,10 +20,10 @@ type NodeGetter interface {
// Get retrieves nodes by CID. Depending on the NodeGetter
// implementation, this may involve fetching the Node from a remote
// machine; consider setting a deadline in the context.
Get(context.Context, *cid.Cid) (Node, error)
Get(context.Context, cid.Cid) (Node, error)
// GetMany returns a channel of NodeOptions given a set of CIDs.
GetMany(context.Context, []*cid.Cid) <-chan *NodeOption
GetMany(context.Context, []cid.Cid) <-chan *NodeOption
}
// NodeGetters can optionally implement this interface to make finding linked
......@@ -31,11 +31,11 @@ type NodeGetter interface {
type LinkGetter interface {
NodeGetter
// TODO(ipfs/go-ipld-format#9): This should return []*cid.Cid
// TODO(ipfs/go-ipld-format#9): This should return []cid.Cid
// GetLinks returns the children of the node refered to by the given
// CID.
GetLinks(ctx context.Context, nd *cid.Cid) ([]*Link, error)
GetLinks(ctx context.Context, nd cid.Cid) ([]*Link, error)
}
// DAGService is an IPFS Merkle DAG service.
......@@ -48,7 +48,7 @@ type DAGService interface {
// Remove removes a node from this DAG.
//
// Remove returns no error if the requested node is not present in this DAG.
Remove(context.Context, *cid.Cid) error
Remove(context.Context, cid.Cid) error
// AddMany adds many nodes to this DAG.
//
......@@ -59,5 +59,5 @@ type DAGService interface {
// RemoveMany removes many nodes from this DAG.
//
// It returns success even if the nodes were not present in the DAG.
RemoveMany(context.Context, []*cid.Cid) error
RemoveMany(context.Context, []cid.Cid) error
}
......@@ -9,15 +9,15 @@
"gxDependencies": [
{
"author": "whyrusleeping",
"hash": "QmZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb",
"hash": "QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7",
"name": "go-cid",
"version": "0.8.0"
"version": "0.9.0"
},
{
"author": "stebalien",
"hash": "QmWAzSEoqZ6xU6pu8yL8e5WaMb7wtbfbhhN4p1DknUPtr3",
"hash": "QmRcHuYzAyswytBuMF78rj3LTChYszomRFXNg4685ZN1WM",
"name": "go-block-format",
"version": "0.1.11"
"version": "0.2.0"
},
{
"author": "multiformats",
......
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