Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gx update and fix code to use new Cid type #42

Merged
merged 2 commits into from
Sep 12, 2018
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 @@
0.5.8: QmX5CsuHyVZeTLxgRSYkgLSDQKb9UjE8xnhQzCEJWWWFsC
0.6.0: QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL
8 changes: 4 additions & 4 deletions batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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))
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions daghelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions daghelpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions merkledag.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ 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
// objects faster.
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.
Expand All @@ -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.
//
Expand All @@ -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
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -31,6 +31,6 @@
"license": "",
"name": "go-ipld-format",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "0.5.8"
"version": "0.6.0"
}