Skip to content

Commit

Permalink
Merge pull request ipfs#6 from geoah/master
Browse files Browse the repository at this point in the history
[wip] Finish dependency extraction
  • Loading branch information
whyrusleeping committed Sep 4, 2016
2 parents 22eec13 + 1dffd86 commit 02dc940
Show file tree
Hide file tree
Showing 20 changed files with 147 additions and 192 deletions.
2 changes: 1 addition & 1 deletion .gx/lastpubver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0: QmSS5fXJLErnboqmkauLwRrEDAij2MEyvqcwgJ9fF5k2s2
1.0.1: QmSXEMQ9yXxVm84YNXXyyDzu5gyHa3K8FYSfwzPjNXSfHq
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ os:
language: go

go:
- 1.5.2

env:
- GO15VENDOREXPERIMENT=1
- 1.7

install: true

Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ gx:

deps: gx
gx --verbose install --global
gx-go rewrite
go get ./...
gx-go rewrite
30 changes: 15 additions & 15 deletions dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ import (
"sync"
"time"

key "github.com/ipfs/go-ipfs/blocks/key"
routing "github.com/ipfs/go-ipfs/routing"
pb "github.com/ipfs/go-ipfs/routing/dht/pb"
providers "github.com/ipfs/go-ipfs/routing/dht/providers"
kb "github.com/ipfs/go-ipfs/routing/kbucket"
record "github.com/ipfs/go-ipfs/routing/record"

proto "github.com/gogo/protobuf/proto"
ds "github.com/ipfs/go-datastore"
key "github.com/ipfs/go-key"
ci "github.com/ipfs/go-libp2p-crypto"
peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
host "github.com/ipfs/go-libp2p/p2p/host"
protocol "github.com/ipfs/go-libp2p/p2p/protocol"
logging "github.com/ipfs/go-log"
goprocess "github.com/jbenet/goprocess"
goprocessctx "github.com/jbenet/goprocess/context"
pb "github.com/libp2p/go-libp2p-kad-dht/pb"
providers "github.com/libp2p/go-libp2p-kad-dht/providers"
kb "github.com/libp2p/go-libp2p-kbucket"
record "github.com/libp2p/go-libp2p-record"
recpb "github.com/libp2p/go-libp2p-record/pb"
routing "github.com/libp2p/go-libp2p-routing"
host "github.com/libp2p/go-libp2p/p2p/host"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
context "golang.org/x/net/context"
)

Expand Down Expand Up @@ -103,7 +103,7 @@ func NewDHT(ctx context.Context, h host.Host, dstore ds.Batching) *IpfsDHT {

// putValueToPeer stores the given key/value pair at the peer 'p'
func (dht *IpfsDHT) putValueToPeer(ctx context.Context, p peer.ID,
key key.Key, rec *pb.Record) error {
key key.Key, rec *recpb.Record) error {

pmes := pb.NewMessage(pb.Message_PUT_VALUE, string(key), 0)
pmes.Record = rec
Expand Down Expand Up @@ -135,7 +135,7 @@ var errInvalidRecord = errors.New("received invalid record")
// NOTE: It will update the dht's peerstore with any new addresses
// it finds for the given peer.
func (dht *IpfsDHT) getValueOrPeers(ctx context.Context, p peer.ID,
key key.Key) (*pb.Record, []pstore.PeerInfo, error) {
key key.Key) (*recpb.Record, []pstore.PeerInfo, error) {

pmes, err := dht.getValueSingle(ctx, p, key)
if err != nil {
Expand All @@ -155,7 +155,7 @@ func (dht *IpfsDHT) getValueOrPeers(ctx context.Context, p peer.ID,
log.Info("Received invalid record! (discarded)")
// return a sentinal to signify an invalid record was received
err = errInvalidRecord
record = new(pb.Record)
record = new(recpb.Record)
}
return record, peers, err
}
Expand Down Expand Up @@ -188,7 +188,7 @@ func (dht *IpfsDHT) getValueSingle(ctx context.Context, p peer.ID,
}

// getLocal attempts to retrieve the value from the datastore
func (dht *IpfsDHT) getLocal(key key.Key) (*pb.Record, error) {
func (dht *IpfsDHT) getLocal(key key.Key) (*recpb.Record, error) {

log.Debug("getLocal %s", key)
v, err := dht.datastore.Get(key.DsKey())
Expand All @@ -201,7 +201,7 @@ func (dht *IpfsDHT) getLocal(key key.Key) (*pb.Record, error) {
if !ok {
return nil, errors.New("value stored in datastore not []byte")
}
rec := new(pb.Record)
rec := new(recpb.Record)
err = proto.Unmarshal(byt, rec)
if err != nil {
return nil, err
Expand All @@ -228,7 +228,7 @@ func (dht *IpfsDHT) getOwnPrivateKey() (ci.PrivKey, error) {
}

// putLocal stores the key value pair in the datastore
func (dht *IpfsDHT) putLocal(key key.Key, rec *pb.Record) error {
func (dht *IpfsDHT) putLocal(key key.Key, rec *recpb.Record) error {
data, err := proto.Marshal(rec)
if err != nil {
return err
Expand Down
3 changes: 1 addition & 2 deletions dht_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import (
"time"

u "github.com/ipfs/go-ipfs-util"
routing "github.com/ipfs/go-ipfs/routing"
peer "github.com/ipfs/go-libp2p-peer"

goprocess "github.com/jbenet/goprocess"
periodicproc "github.com/jbenet/goprocess/periodic"
routing "github.com/libp2p/go-libp2p-routing"
context "golang.org/x/net/context"
)

Expand Down
7 changes: 4 additions & 3 deletions dht_net.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"time"

ggio "github.com/gogo/protobuf/io"
pb "github.com/ipfs/go-ipfs/routing/dht/pb"
peer "github.com/ipfs/go-libp2p-peer"
inet "github.com/ipfs/go-libp2p/p2p/net"
ctxio "github.com/jbenet/go-context/io"
inet "github.com/libp2p/go-libp2p/p2p/net"
context "golang.org/x/net/context"

pb "github.com/libp2p/go-libp2p-kad-dht/pb"
)

var dhtReadMessageTimeout = time.Minute
Expand Down Expand Up @@ -141,7 +142,7 @@ func (ms *messageSender) prep() error {
return nil
}

nstr, err := ms.dht.host.NewStream(ms.dht.ctx, ProtocolDHT, ms.p)
nstr, err := ms.dht.host.NewStream(ms.dht.ctx, ms.p, ProtocolDHT)
if err != nil {
return err
}
Expand Down
13 changes: 6 additions & 7 deletions dht_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ import (

ds "github.com/ipfs/go-datastore"
dssync "github.com/ipfs/go-datastore/sync"
key "github.com/ipfs/go-ipfs/blocks/key"
routing "github.com/ipfs/go-ipfs/routing"
record "github.com/ipfs/go-ipfs/routing/record"
ci "github.com/ipfs/go-ipfs/thirdparty/testutil/ci"
travisci "github.com/ipfs/go-ipfs/thirdparty/testutil/ci/travis"

u "github.com/ipfs/go-ipfs-util"
key "github.com/ipfs/go-key"
peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
netutil "github.com/ipfs/go-libp2p/p2p/test/util"
ma "github.com/jbenet/go-multiaddr"
record "github.com/libp2p/go-libp2p-record"
routing "github.com/libp2p/go-libp2p-routing"
netutil "github.com/libp2p/go-libp2p/p2p/test/util"
ci "github.com/libp2p/go-testutil/ci"
travisci "github.com/libp2p/go-testutil/ci/travis"
context "golang.org/x/net/context"
)

Expand Down
18 changes: 9 additions & 9 deletions ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import (
"testing"
"time"

ggio "github.com/gogo/protobuf/io"
ds "github.com/ipfs/go-datastore"
dssync "github.com/ipfs/go-datastore/sync"
key "github.com/ipfs/go-ipfs/blocks/key"
routing "github.com/ipfs/go-ipfs/routing"
pb "github.com/ipfs/go-ipfs/routing/dht/pb"
record "github.com/ipfs/go-ipfs/routing/record"

ggio "github.com/gogo/protobuf/io"
u "github.com/ipfs/go-ipfs-util"
key "github.com/ipfs/go-key"
pstore "github.com/ipfs/go-libp2p-peerstore"
inet "github.com/ipfs/go-libp2p/p2p/net"
mocknet "github.com/ipfs/go-libp2p/p2p/net/mock"
record "github.com/libp2p/go-libp2p-record"
routing "github.com/libp2p/go-libp2p-routing"
inet "github.com/libp2p/go-libp2p/p2p/net"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
context "golang.org/x/net/context"

pb "github.com/libp2p/go-libp2p-kad-dht/pb"
)

func TestGetFailures(t *testing.T) {
Expand Down Expand Up @@ -118,7 +118,7 @@ func TestGetFailures(t *testing.T) {
Record: rec,
}

s, err := hosts[1].NewStream(context.Background(), ProtocolDHT, hosts[0].ID())
s, err := hosts[1].NewStream(context.Background(), hosts[0].ID(), ProtocolDHT)
if err != nil {
t.Fatal(err)
}
Expand Down
14 changes: 7 additions & 7 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import (
"fmt"
"time"

ds "github.com/ipfs/go-datastore"
key "github.com/ipfs/go-ipfs/blocks/key"
pb "github.com/ipfs/go-ipfs/routing/dht/pb"
lgbl "github.com/ipfs/go-ipfs/thirdparty/loggables"

proto "github.com/gogo/protobuf/proto"
ds "github.com/ipfs/go-datastore"
u "github.com/ipfs/go-ipfs-util"
key "github.com/ipfs/go-key"
lgbl "github.com/ipfs/go-libp2p-loggables"
peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
pb "github.com/libp2p/go-libp2p-kad-dht/pb"
recpb "github.com/libp2p/go-libp2p-record/pb"
context "golang.org/x/net/context"
)

Expand Down Expand Up @@ -82,7 +82,7 @@ func (dht *IpfsDHT) handleGetValue(ctx context.Context, p peer.ID, pmes *pb.Mess
return resp, nil
}

func (dht *IpfsDHT) checkLocalDatastore(k key.Key) (*pb.Record, error) {
func (dht *IpfsDHT) checkLocalDatastore(k key.Key) (*recpb.Record, error) {
log.Debugf("%s handleGetValue looking into ds", dht.self)
dskey := k.DsKey()
iVal, err := dht.datastore.Get(dskey)
Expand All @@ -105,7 +105,7 @@ func (dht *IpfsDHT) checkLocalDatastore(k key.Key) (*pb.Record, error) {
return nil, fmt.Errorf("datastore had non byte-slice value for %v", dskey)
}

rec := new(pb.Record)
rec := new(recpb.Record)
err = proto.Unmarshal(byts, rec)
if err != nil {
log.Debug("failed to unmarshal DHT record from datastore")
Expand Down
9 changes: 4 additions & 5 deletions lookup.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package dht

import (
key "github.com/ipfs/go-ipfs/blocks/key"
notif "github.com/ipfs/go-ipfs/notifications"
kb "github.com/ipfs/go-ipfs/routing/kbucket"
pset "github.com/ipfs/go-ipfs/thirdparty/peerset"

key "github.com/ipfs/go-key"
peer "github.com/ipfs/go-libp2p-peer"
pset "github.com/ipfs/go-libp2p-peer/peerset"
pstore "github.com/ipfs/go-libp2p-peerstore"
kb "github.com/libp2p/go-libp2p-kbucket"
notif "github.com/libp2p/go-libp2p-routing/notifications"
context "golang.org/x/net/context"
)

Expand Down
3 changes: 1 addition & 2 deletions notif.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package dht

import (
ma "github.com/jbenet/go-multiaddr"

inet "github.com/ipfs/go-libp2p/p2p/net"
inet "github.com/libp2p/go-libp2p/p2p/net"
)

// netNotifiee defines methods to be used with the IpfsDHT
Expand Down
Loading

0 comments on commit 02dc940

Please sign in to comment.