@cryptotaxi247 / kubo / commits / b64d17b92

properly expose dual dht

Steven Allen committed Apr 13, 2020 at 15:58 UTC b64d17b9241ee0024522bbb4d6a450131b00f443
3 files changed +14 -8
core/commands/dht.go
+6 -1
@@ -76,7 +76,12 @@ var queryDhtCmd = &cmds.Command{
76 ctx, cancel := context.WithCancel(req.Context)
77 ctx, events := routing.RegisterForQueryEvents(ctx)
78
79 - closestPeers, err := nd.DHT.GetClosestPeers(ctx, string(id))
79 + dht := nd.DHT.WAN
80 + if !nd.DHT.WANActive() {
81 + dht = nd.DHT.LAN
82 + }
83 +
84 + closestPeers, err := dht.GetClosestPeers(ctx, string(id))
85 if err != nil {
86 cancel()
87 return err
core/core.go
+2 -2
@@ -33,7 +33,7 @@ import (
33 peer "github.com/libp2p/go-libp2p-core/peer"
34 pstore "github.com/libp2p/go-libp2p-core/peerstore"
35 routing "github.com/libp2p/go-libp2p-core/routing"
36 - dht "github.com/libp2p/go-libp2p-kad-dht"
36 + ddht "github.com/libp2p/go-libp2p-kad-dht/dual"
37 pubsub "github.com/libp2p/go-libp2p-pubsub"
38 psrouter "github.com/libp2p/go-libp2p-pubsub-router"
39 record "github.com/libp2p/go-libp2p-record"
@@ -92,7 +92,7 @@ type IpfsNode struct {
92
93 PubSub *pubsub.PubSub `optional:"true"`
94 PSRouter *psrouter.PubsubValueStore `optional:"true"`
95 - DHT *dht.IpfsDHT `optional:"true"`
95 + DHT *ddht.DHT `optional:"true"`
96 P2P *p2p.P2P `optional:"true"`
97
98 Process goprocess.Process
core/node/libp2p/routing.go
+6 -5
@@ -5,16 +5,17 @@ import (
5 "sort"
6 "time"
7
8 + "github.com/ipfs/go-ipfs/core/node/helpers"
9 +
10 host "github.com/libp2p/go-libp2p-core/host"
11 routing "github.com/libp2p/go-libp2p-core/routing"
10 - dht "github.com/libp2p/go-libp2p-kad-dht"
12 + ddht "github.com/libp2p/go-libp2p-kad-dht/dual"
13 "github.com/libp2p/go-libp2p-pubsub"
14 namesys "github.com/libp2p/go-libp2p-pubsub-router"
15 record "github.com/libp2p/go-libp2p-record"
16 routinghelpers "github.com/libp2p/go-libp2p-routing-helpers"
15 - "go.uber.org/fx"
17
17 - "github.com/ipfs/go-ipfs/core/node/helpers"
18 + "go.uber.org/fx"
19 )
20
21 type BaseIpfsRouting routing.Routing
@@ -31,8 +32,8 @@ type p2pRouterOut struct {
32 Router Router `group:"routers"`
33 }
34
34 -func BaseRouting(lc fx.Lifecycle, in BaseIpfsRouting) (out p2pRouterOut, dr *dht.IpfsDHT) {
35 - if dht, ok := in.(*dht.IpfsDHT); ok {
35 +func BaseRouting(lc fx.Lifecycle, in BaseIpfsRouting) (out p2pRouterOut, dr *ddht.DHT) {
36 + if dht, ok := in.(*ddht.DHT); ok {
37 dr = dht
38
39 lc.Append(fx.Hook{