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 authored 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.