mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-02 03:28:25 +08:00
add Peerstore to dht
This commit is contained in:

committed by
Brian Tiger Chow

parent
c4fa995faf
commit
e4e021085b
@ -103,7 +103,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
route = dht.NewDHT(local, net, dhts, d)
|
||||
route = dht.NewDHT(local, peerstore, net, dhts, d)
|
||||
dhts.Handler = route // wire the handler to the service.
|
||||
|
||||
// TODO(brian): pass a context to DHT for its async operations
|
||||
|
@ -36,6 +36,9 @@ type IpfsDHT struct {
|
||||
// Local peer (yourself)
|
||||
self *peer.Peer
|
||||
|
||||
// Other peers
|
||||
peerstore peer.Peerstore
|
||||
|
||||
// Local data
|
||||
datastore ds.Datastore
|
||||
dslock sync.Mutex
|
||||
@ -53,12 +56,13 @@ type IpfsDHT struct {
|
||||
}
|
||||
|
||||
// NewDHT creates a new DHT object with the given peer as the 'local' host
|
||||
func NewDHT(p *peer.Peer, net inet.Network, sender inet.Sender, dstore ds.Datastore) *IpfsDHT {
|
||||
func NewDHT(p *peer.Peer, ps peer.Peerstore, net inet.Network, sender inet.Sender, dstore ds.Datastore) *IpfsDHT {
|
||||
dht := new(IpfsDHT)
|
||||
dht.network = net
|
||||
dht.sender = sender
|
||||
dht.datastore = dstore
|
||||
dht.self = p
|
||||
dht.peerstore = ps
|
||||
|
||||
dht.providers = NewProviderManager(p.ID)
|
||||
dht.shutdown = make(chan struct{})
|
||||
|
Reference in New Issue
Block a user