core dht setup
Juan Batiz-Benet committed
Sep 16, 2014 at 00:51 UTC
27d0e692ed1a2d6763f56241fdc966395a1b5e1d
1 file changed
+13
-3
core/core.go
+13
-3
@@ -17,6 +17,7 @@ import (
17
merkledag "github.com/jbenet/go-ipfs/merkledag"
18
inet "github.com/jbenet/go-ipfs/net"
19
mux "github.com/jbenet/go-ipfs/net/mux"
20
+ netservice "github.com/jbenet/go-ipfs/net/service"
21
path "github.com/jbenet/go-ipfs/path"
22
peer "github.com/jbenet/go-ipfs/peer"
23
routing "github.com/jbenet/go-ipfs/routing"
@@ -85,15 +86,24 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
86
87
if online {
88
// add protocol services here.
89
+ ctx := context.TODO() // derive this from a higher context.
90
+
91
+ dhts := netservice.Service(nil) // nil handler for now, need to patch it
92
+ if err := dhts.Start(ctx); err != nil {
93
+ return nil, err
94
+ }
95
+
96
net, err := inet.NewIpfsNetwork(context.TODO(), local, &mux.ProtocolMap{
89
- // "1": dhtService,
90
- // "2": bitswapService,
97
+ netservice.ProtocolID_Routing: dhtService,
98
+ // netservice.ProtocolID_Bitswap: bitswapService,
99
})
100
if err != nil {
101
return nil, err
102
}
103
96
- route = dht.NewDHT(local, net, d)
104
+ route = dht.NewDHT(local, net, dhts, d)
105
+ dhts.Handler = route // wire the handler to the service.
106
+
107
// TODO(brian): pass a context to DHT for its async operations
108
route.Start()
109