Skip to content

Commit

Permalink
Merge pull request #233 from libp2p/update
Browse files Browse the repository at this point in the history
upgrade dependencies.
  • Loading branch information
Stebalien authored Aug 19, 2020
2 parents 4169fec + a8fad0c commit 9ecfdc5
Show file tree
Hide file tree
Showing 12 changed files with 398 additions and 420 deletions.
14 changes: 3 additions & 11 deletions daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ import (

multierror "github.com/hashicorp/go-multierror"
logging "github.com/ipfs/go-log"
autonat "github.com/libp2p/go-libp2p-autonat-svc"
dht "github.com/libp2p/go-libp2p-kad-dht"
dhtopts "github.com/libp2p/go-libp2p-kad-dht/opts"
ps "github.com/libp2p/go-libp2p-pubsub"
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
manet "github.com/multiformats/go-multiaddr/net"
)

var log = logging.Logger("p2pd")
Expand All @@ -32,9 +31,8 @@ type Daemon struct {
host host.Host
listener manet.Listener

dht *dht.IpfsDHT
pubsub *ps.PubSub
autonat *autonat.AutoNATService
dht *dht.IpfsDHT
pubsub *ps.PubSub

mx sync.Mutex
// stream handlers: map of protocol.ID to multi-address
Expand Down Expand Up @@ -126,12 +124,6 @@ func (d *Daemon) EnablePubsub(router string, sign, strict bool) error {

}

func (d *Daemon) EnableAutoNAT(opts ...libp2p.Option) error {
svc, err := autonat.NewAutoNATService(d.ctx, d.host, opts...)
d.autonat = svc
return err
}

func (d *Daemon) ID() peer.ID {
return d.host.ID()
}
Expand Down
37 changes: 4 additions & 33 deletions dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
"github.com/libp2p/go-libp2p-core/peer"

cid "github.com/ipfs/go-cid"
dht "github.com/libp2p/go-libp2p-kad-dht"
)

const defaultProviderCount = 20

func (d *Daemon) doDHT(req *pb.Request) (*pb.Response, <-chan *pb.DHTResponse, func()) {
if d.dht == nil {
return errorResponseString("DHT not enabled"), nil, nil
Expand Down Expand Up @@ -77,37 +78,7 @@ func (d *Daemon) doDHTFindPeer(req *pb.DHTRequest) (*pb.Response, <-chan *pb.DHT
}

func (d *Daemon) doDHTFindPeersConnectedToPeer(req *pb.DHTRequest) (*pb.Response, <-chan *pb.DHTResponse, func()) {
if req.Peer == nil {
return errorResponseString("Malformed request; missing peer parameter"), nil, nil
}

p, err := peer.IDFromBytes(req.Peer)
if err != nil {
return errorResponse(err), nil, nil
}

ctx, cancel := d.dhtRequestContext(req)

ch, err := d.dht.FindPeersConnectedToPeer(ctx, p)
if err != nil {
cancel()
return errorResponse(err), nil, nil
}

rch := make(chan *pb.DHTResponse)
go func() {
defer cancel()
defer close(rch)
for pi := range ch {
select {
case rch <- dhtResponsePeerInfo(*pi):
case <-ctx.Done():
return
}
}
}()

return dhtOkResponse(dhtResponseBegin()), rch, cancel
return errorResponseString("not supported"), nil, nil
}

func (d *Daemon) doDHTFindProviders(req *pb.DHTRequest) (*pb.Response, <-chan *pb.DHTResponse, func()) {
Expand All @@ -120,7 +91,7 @@ func (d *Daemon) doDHTFindProviders(req *pb.DHTRequest) (*pb.Response, <-chan *p
return errorResponse(err), nil, nil
}

count := dht.KValue
count := defaultProviderCount
if req.GetCount() > 0 {
count = int(*req.Count)
}
Expand Down
49 changes: 22 additions & 27 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,29 @@ module github.com/libp2p/go-libp2p-daemon
go 1.12

require (
github.com/ChainSafe/log15 v1.0.0 // indirect
github.com/gogo/protobuf v1.3.1
github.com/hashicorp/go-multierror v1.0.0
github.com/ipfs/go-cid v0.0.5
github.com/ipfs/go-log v1.0.3
github.com/libp2p/go-libp2p v0.8.1
github.com/libp2p/go-libp2p-autonat-svc v0.1.0
github.com/libp2p/go-libp2p-circuit v0.2.1
github.com/libp2p/go-libp2p-connmgr v0.1.1
github.com/libp2p/go-libp2p-core v0.5.1
github.com/libp2p/go-libp2p-kad-dht v0.3.2
github.com/libp2p/go-libp2p-noise v0.1.1-0.20200507064022-02dc2ad5c414
github.com/libp2p/go-libp2p-peerstore v0.2.2
github.com/libp2p/go-libp2p-pubsub v0.2.4
github.com/libp2p/go-libp2p-quic-transport v0.2.2
github.com/hashicorp/go-multierror v1.1.0
github.com/ipfs/go-cid v0.0.7
github.com/ipfs/go-log v1.0.4
github.com/libp2p/go-libp2p v0.10.3
github.com/libp2p/go-libp2p-circuit v0.3.1
github.com/libp2p/go-libp2p-connmgr v0.2.4
github.com/libp2p/go-libp2p-core v0.6.1
github.com/libp2p/go-libp2p-kad-dht v0.8.3
github.com/libp2p/go-libp2p-noise v0.1.1
github.com/libp2p/go-libp2p-peerstore v0.2.6
github.com/libp2p/go-libp2p-pubsub v0.3.4
github.com/libp2p/go-libp2p-quic-transport v0.7.1
github.com/libp2p/go-libp2p-secio v0.2.2
github.com/libp2p/go-libp2p-tls v0.1.3
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.11 // indirect
github.com/multiformats/go-multiaddr v0.2.1
github.com/multiformats/go-multiaddr-net v0.1.4
github.com/multiformats/go-multihash v0.0.13
github.com/prometheus/client_golang v1.2.1
github.com/stretchr/testify v1.5.1
github.com/whyrusleeping/go-logging v0.0.1 // indirect
go.uber.org/atomic v1.5.1 // indirect
go.uber.org/multierr v1.4.0 // indirect
go.uber.org/zap v1.13.0 // indirect
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect
github.com/multiformats/go-multiaddr v0.3.0
github.com/multiformats/go-multiaddr-net v0.2.0 // indirect
github.com/multiformats/go-multihash v0.0.14
github.com/prometheus/client_golang v1.7.1
github.com/stretchr/testify v1.6.1
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 // indirect
golang.org/x/net v0.0.0-20200602114024-627f9648deb9 // indirect
google.golang.org/protobuf v1.24.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200602154603-c1a7af8cc6cd // indirect
)
Loading

0 comments on commit 9ecfdc5

Please sign in to comment.