mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-28 17:03:58 +08:00
core dht setup
This commit is contained in:

committed by
Brian Tiger Chow

parent
865109f562
commit
27d0e692ed
16
core/core.go
16
core/core.go
@ -17,6 +17,7 @@ import (
|
|||||||
merkledag "github.com/jbenet/go-ipfs/merkledag"
|
merkledag "github.com/jbenet/go-ipfs/merkledag"
|
||||||
inet "github.com/jbenet/go-ipfs/net"
|
inet "github.com/jbenet/go-ipfs/net"
|
||||||
mux "github.com/jbenet/go-ipfs/net/mux"
|
mux "github.com/jbenet/go-ipfs/net/mux"
|
||||||
|
netservice "github.com/jbenet/go-ipfs/net/service"
|
||||||
path "github.com/jbenet/go-ipfs/path"
|
path "github.com/jbenet/go-ipfs/path"
|
||||||
peer "github.com/jbenet/go-ipfs/peer"
|
peer "github.com/jbenet/go-ipfs/peer"
|
||||||
routing "github.com/jbenet/go-ipfs/routing"
|
routing "github.com/jbenet/go-ipfs/routing"
|
||||||
@ -85,15 +86,24 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
|
|||||||
|
|
||||||
if online {
|
if online {
|
||||||
// add protocol services here.
|
// add protocol services here.
|
||||||
|
ctx := context.TODO() // derive this from a higher context.
|
||||||
|
|
||||||
|
dhts := netservice.Service(nil) // nil handler for now, need to patch it
|
||||||
|
if err := dhts.Start(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
net, err := inet.NewIpfsNetwork(context.TODO(), local, &mux.ProtocolMap{
|
net, err := inet.NewIpfsNetwork(context.TODO(), local, &mux.ProtocolMap{
|
||||||
// "1": dhtService,
|
netservice.ProtocolID_Routing: dhtService,
|
||||||
// "2": bitswapService,
|
// netservice.ProtocolID_Bitswap: bitswapService,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
route = dht.NewDHT(local, net, d)
|
route = dht.NewDHT(local, net, dhts, d)
|
||||||
|
dhts.Handler = route // wire the handler to the service.
|
||||||
|
|
||||||
// TODO(brian): pass a context to DHT for its async operations
|
// TODO(brian): pass a context to DHT for its async operations
|
||||||
route.Start()
|
route.Start()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user