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

completely remove go-key dep #3439

Merged
merged 1 commit into from
Nov 29, 2016
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
8 changes: 4 additions & 4 deletions core/builder.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package core

import (
"context"
"crypto/rand"
"encoding/base64"
"errors"
Expand All @@ -17,14 +18,13 @@ import (
repo "github.com/ipfs/go-ipfs/repo"
cfg "github.com/ipfs/go-ipfs/repo/config"

context "context"
retry "gx/ipfs/QmPF5kxTYFkzhaY5LmkExood7aTTZBHWQC6cjdDQBuGrjp/retry-datastore"
metrics "gx/ipfs/QmRg1gKTHzc3CZXSKzem8aR4E3TubFhbgXwfVuWnSK5CC5/go-metrics-interface"
goprocessctx "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/context"
pstore "gx/ipfs/QmXXCcQ7CLg5a81Ui9TTR35QcR4y7ZyihxwfjqaHfUVcVo/go-libp2p-peerstore"
key "gx/ipfs/QmYEoKZXHoAToWfhGF3vryhMn3WWhE1o2MasQ8uzY5iDi9/go-key"
ds "gx/ipfs/QmbzuUusHqaLLoNTDEVLcSF6vZDHZDLPC7p4bztRvvkXxU/go-datastore"
dsync "gx/ipfs/QmbzuUusHqaLLoNTDEVLcSF6vZDHZDLPC7p4bztRvvkXxU/go-datastore/sync"
peer "gx/ipfs/QmfMmLGoKzCHDN7cGgk64PJr4iipzidDRME8HABSJqvmhC/go-libp2p-peer"
ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto"
)

Expand Down Expand Up @@ -91,7 +91,7 @@ func defaultRepo(dstore repo.Datastore) (repo.Repo, error) {
return nil, err
}

data, err := pub.Hash()
pid, err := peer.IDFromPublicKey(pub)
if err != nil {
return nil, err
}
Expand All @@ -103,7 +103,7 @@ func defaultRepo(dstore repo.Datastore) (repo.Repo, error) {

c.Bootstrap = cfg.DefaultBootstrapAddresses
c.Addresses.Swarm = []string{"/ip4/0.0.0.0/tcp/4001"}
c.Identity.PeerID = key.Key(data).B58String()
c.Identity.PeerID = pid.Pretty()
c.Identity.PrivKey = base64.StdEncoding.EncodeToString(privkeyb)

return &repo.Mock{
Expand Down
10 changes: 5 additions & 5 deletions core/commands/publish.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package commands

import (
"context"
"errors"
"fmt"
"io"
"strings"
"time"

context "context"

cmds "github.com/ipfs/go-ipfs/commands"
core "github.com/ipfs/go-ipfs/core"
path "github.com/ipfs/go-ipfs/path"
key "gx/ipfs/QmYEoKZXHoAToWfhGF3vryhMn3WWhE1o2MasQ8uzY5iDi9/go-key"

peer "gx/ipfs/QmfMmLGoKzCHDN7cGgk64PJr4iipzidDRME8HABSJqvmhC/go-libp2p-peer"
crypto "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto"
)

Expand Down Expand Up @@ -147,13 +147,13 @@ func publish(ctx context.Context, n *core.IpfsNode, k crypto.PrivKey, ref path.P
return nil, err
}

hash, err := k.GetPublic().Hash()
pid, err := peer.IDFromPrivateKey(k)
if err != nil {
return nil, err
}

return &IpnsEntry{
Name: key.Key(hash).String(),
Name: pid.Pretty(),
Value: ref.String(),
}, nil
}
16 changes: 8 additions & 8 deletions fuse/ipns/ipns_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@
package ipns

import (
"context"
"errors"
"fmt"
"os"

"context"
fuse "github.com/ipfs/go-ipfs/Godeps/_workspace/src/bazil.org/fuse"
fs "github.com/ipfs/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs"
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"

core "github.com/ipfs/go-ipfs/core"
dag "github.com/ipfs/go-ipfs/merkledag"
mfs "github.com/ipfs/go-ipfs/mfs"
path "github.com/ipfs/go-ipfs/path"
ft "github.com/ipfs/go-ipfs/unixfs"
key "gx/ipfs/QmYEoKZXHoAToWfhGF3vryhMn3WWhE1o2MasQ8uzY5iDi9/go-key"

logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
cid "gx/ipfs/QmcEcrBAMrwMyhSjXt4yfyPpzgSuV8HLHavnfmiKCSRqZU/go-cid"
peer "gx/ipfs/QmfMmLGoKzCHDN7cGgk64PJr4iipzidDRME8HABSJqvmhC/go-libp2p-peer"
ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto"
)

Expand Down Expand Up @@ -135,11 +136,11 @@ func CreateRoot(ipfs *core.IpfsNode, keys map[string]ci.PrivKey, ipfspath, ipnsp
roots := make(map[string]*keyRoot)
links := make(map[string]*Link)
for alias, k := range keys {
pkh, err := k.GetPublic().Hash()
pid, err := peer.IDFromPrivateKey(k)
if err != nil {
return nil, err
}
name := key.Key(pkh).B58String()
name := pid.Pretty()

kr := &keyRoot{k: k, alias: alias}
fsn, err := loadRoot(ipfs.Context(), kr, ipfs, name)
Expand Down Expand Up @@ -241,13 +242,12 @@ func (r *Root) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {

var listing []fuse.Dirent
for alias, k := range r.Keys {
pub := k.GetPublic()
hash, err := pub.Hash()
pid, err := peer.IDFromPrivateKey(k)
if err != nil {
continue
}
ent := fuse.Dirent{
Name: key.Key(hash).B58String(),
Name: pid.Pretty(),
Type: fuse.DT_Dir,
}
link := fuse.Dirent{
Expand Down
9 changes: 4 additions & 5 deletions merkledag/merkledag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
uio "github.com/ipfs/go-ipfs/unixfs/io"

node "gx/ipfs/QmUsVJ7AEnGyjX8YWnrwq9vmECVGwBQNAKPpgz5KSg8dcq/go-ipld-node"
key "gx/ipfs/QmYEoKZXHoAToWfhGF3vryhMn3WWhE1o2MasQ8uzY5iDi9/go-key"
u "gx/ipfs/Qmb912gdngC1UWwTkhuW8knyRbcWeu5kqkxBpveLmW8bSr/go-ipfs-util"
cid "gx/ipfs/QmcEcrBAMrwMyhSjXt4yfyPpzgSuV8HLHavnfmiKCSRqZU/go-cid"
)
Expand Down Expand Up @@ -56,8 +55,8 @@ func TestNode(t *testing.T) {
}

h := n.Multihash()
k := n.Key()
if k != key.Key(h) {
k := n.Cid().Hash()
if k.String() != h.String() {
t.Error("Key is not equivalent to multihash")
} else {
fmt.Println("key: ", k)
Expand All @@ -84,15 +83,15 @@ func SubtestNodeStat(t *testing.T, n *ProtoNode) {
return
}

k := n.Key()
k := n.Cid()

expected := node.NodeStat{
NumLinks: len(n.Links()),
BlockSize: len(enc),
LinksSize: len(enc) - len(n.Data()), // includes framing.
DataSize: len(n.Data()),
CumulativeSize: int(cumSize),
Hash: k.B58String(),
Hash: k.String(),
}

actual, err := n.Stat()
Expand Down
7 changes: 1 addition & 6 deletions merkledag/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

node "gx/ipfs/QmUsVJ7AEnGyjX8YWnrwq9vmECVGwBQNAKPpgz5KSg8dcq/go-ipld-node"
mh "gx/ipfs/QmYDds3421prZgqKbLpEK7T9Aa2eVdQ7o3YarX1LVLdP2J/go-multihash"
key "gx/ipfs/QmYEoKZXHoAToWfhGF3vryhMn3WWhE1o2MasQ8uzY5iDi9/go-key"
cid "gx/ipfs/QmcEcrBAMrwMyhSjXt4yfyPpzgSuV8HLHavnfmiKCSRqZU/go-cid"
)

Expand Down Expand Up @@ -204,7 +203,7 @@ func (n *ProtoNode) Stat() (*node.NodeStat, error) {
}

return &node.NodeStat{
Hash: n.Key().B58String(),
Hash: n.Cid().String(),
NumLinks: len(n.links),
BlockSize: len(enc),
LinksSize: len(enc) - len(n.data), // includes framing.
Expand All @@ -213,10 +212,6 @@ func (n *ProtoNode) Stat() (*node.NodeStat, error) {
}, nil
}

func (n *ProtoNode) Key() key.Key {
return key.Key(n.Multihash())
}

func (n *ProtoNode) Loggable() map[string]interface{} {
return map[string]interface{}{
"node": n.String(),
Expand Down
10 changes: 4 additions & 6 deletions namesys/resolve_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package namesys

import (
"context"
"errors"
"testing"
"time"

context "context"
path "github.com/ipfs/go-ipfs/path"
mockrouting "github.com/ipfs/go-ipfs/routing/mock"
testutil "github.com/ipfs/go-ipfs/thirdparty/testutil"
key "gx/ipfs/QmYEoKZXHoAToWfhGF3vryhMn3WWhE1o2MasQ8uzY5iDi9/go-key"
u "gx/ipfs/Qmb912gdngC1UWwTkhuW8knyRbcWeu5kqkxBpveLmW8bSr/go-ipfs-util"

ds "gx/ipfs/QmbzuUusHqaLLoNTDEVLcSF6vZDHZDLPC7p4bztRvvkXxU/go-datastore"
dssync "gx/ipfs/QmbzuUusHqaLLoNTDEVLcSF6vZDHZDLPC7p4bztRvvkXxU/go-datastore/sync"
peer "gx/ipfs/QmfMmLGoKzCHDN7cGgk64PJr4iipzidDRME8HABSJqvmhC/go-libp2p-peer"
Expand All @@ -36,13 +35,12 @@ func TestRoutingResolve(t *testing.T) {
t.Fatal(err)
}

pubkb, err := pubk.Bytes()
pid, err := peer.IDFromPublicKey(pubk)
if err != nil {
t.Fatal(err)
}

pkhash := u.Hash(pubkb)
res, err := resolver.Resolve(context.Background(), key.Key(pkhash).B58String())
res, err := resolver.Resolve(context.Background(), pid.Pretty())
if err != nil {
t.Fatal(err)
}
Expand Down
15 changes: 5 additions & 10 deletions namesys/routing.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package namesys

import (
"context"
"fmt"
"strings"
"time"

"context"
lru "gx/ipfs/QmVYxfoJQiZijTgPNHCHgHELvQpbsJNTg6Crmc3dQkj3yy/golang-lru"
mh "gx/ipfs/QmYDds3421prZgqKbLpEK7T9Aa2eVdQ7o3YarX1LVLdP2J/go-multihash"
proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"

pb "github.com/ipfs/go-ipfs/namesys/pb"
path "github.com/ipfs/go-ipfs/path"
routing "gx/ipfs/QmUrCwTDvJgmBbJVHu1HGEyqDaod3dR6sEkZkpxZk4u47c/go-libp2p-routing"
key "gx/ipfs/QmYEoKZXHoAToWfhGF3vryhMn3WWhE1o2MasQ8uzY5iDi9/go-key"

logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
routing "gx/ipfs/QmUrCwTDvJgmBbJVHu1HGEyqDaod3dR6sEkZkpxZk4u47c/go-libp2p-routing"
lru "gx/ipfs/QmVYxfoJQiZijTgPNHCHgHELvQpbsJNTg6Crmc3dQkj3yy/golang-lru"
mh "gx/ipfs/QmYDds3421prZgqKbLpEK7T9Aa2eVdQ7o3YarX1LVLdP2J/go-multihash"
proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
u "gx/ipfs/Qmb912gdngC1UWwTkhuW8knyRbcWeu5kqkxBpveLmW8bSr/go-ipfs-util"
cid "gx/ipfs/QmcEcrBAMrwMyhSjXt4yfyPpzgSuV8HLHavnfmiKCSRqZU/go-cid"
ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto"
Expand Down Expand Up @@ -179,9 +177,6 @@ func (r *routingResolver) resolveOnce(ctx context.Context, name string) (path.Pa
}
}

hsh, _ := pubkey.Hash()
log.Debugf("pk hash = %s", key.Key(hsh))

// check sig with pk
if ok, err := pubkey.Verify(ipnsEntryDataForSig(entry), entry.GetSignature()); err != nil || !ok {
return "", fmt.Errorf("Invalid value. Not signed by PrivateKey corresponding to %v", pubkey)
Expand Down
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,6 @@
"name": "go-cid",
"version": "0.7.5"
},
{
"author": "whyrusleeping",
"hash": "QmYEoKZXHoAToWfhGF3vryhMn3WWhE1o2MasQ8uzY5iDi9",
"name": "go-key",
"version": "1.0.3"
},
{
"author": "whyrusleeping",
"hash": "QmU4VzzKNLJXJ72SedXBQKyf5Jo8W89iWpbWQjHn9qef8N",
Expand Down
15 changes: 7 additions & 8 deletions path/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,23 @@ import (
path "github.com/ipfs/go-ipfs/path"

node "gx/ipfs/QmUsVJ7AEnGyjX8YWnrwq9vmECVGwBQNAKPpgz5KSg8dcq/go-ipld-node"
key "gx/ipfs/QmYEoKZXHoAToWfhGF3vryhMn3WWhE1o2MasQ8uzY5iDi9/go-key"
util "gx/ipfs/Qmb912gdngC1UWwTkhuW8knyRbcWeu5kqkxBpveLmW8bSr/go-ipfs-util"
)

func randNode() (*merkledag.ProtoNode, key.Key) {
func randNode() *merkledag.ProtoNode {
node := new(merkledag.ProtoNode)
node.SetData(make([]byte, 32))
util.NewTimeSeededRand().Read(node.Data())
k := node.Key()
return node, k
return node
}

func TestRecurivePathResolution(t *testing.T) {
ctx := context.Background()
dagService := dagmock.Mock()

a, _ := randNode()
b, _ := randNode()
c, cKey := randNode()
a := randNode()
b := randNode()
c := randNode()

err := b.AddNodeLink("grandchild", c)
if err != nil {
Expand All @@ -47,7 +45,7 @@ func TestRecurivePathResolution(t *testing.T) {
}
}

aKey := a.Key()
aKey := a.Cid()

segments := []string{aKey.String(), "child", "grandchild"}
p, err := path.FromSegments("/ipfs/", segments...)
Expand All @@ -61,6 +59,7 @@ func TestRecurivePathResolution(t *testing.T) {
t.Fatal(err)
}

cKey := c.Cid()
key := node.Cid()
if key.String() != cKey.String() {
t.Fatal(fmt.Errorf(
Expand Down
39 changes: 0 additions & 39 deletions pin/indirect.go

This file was deleted.

9 changes: 0 additions & 9 deletions pin/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/ipfs/go-ipfs/pin/internal/pb"

node "gx/ipfs/QmUsVJ7AEnGyjX8YWnrwq9vmECVGwBQNAKPpgz5KSg8dcq/go-ipld-node"
"gx/ipfs/QmYEoKZXHoAToWfhGF3vryhMn3WWhE1o2MasQ8uzY5iDi9/go-key"
"gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
cid "gx/ipfs/QmcEcrBAMrwMyhSjXt4yfyPpzgSuV8HLHavnfmiKCSRqZU/go-cid"
)
Expand Down Expand Up @@ -308,11 +307,3 @@ func storeSet(ctx context.Context, dag merkledag.DAGService, cids []*cid.Cid, in
internalKeys(c)
return n, nil
}

func copyRefcounts(orig map[key.Key]uint64) map[key.Key]uint64 {
r := make(map[key.Key]uint64, len(orig))
for k, v := range orig {
r[k] = v
}
return r
}
Loading