Skip to content

Commit

Permalink
reorder startup events so that everything but the refresh manager sta…
Browse files Browse the repository at this point in the history
…rts before we add already connected peers to our routing table
  • Loading branch information
aschmahmann committed Dec 2, 2020
1 parent cae3999 commit 33ec247
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
11 changes: 9 additions & 2 deletions dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,21 @@ func New(ctx context.Context, h host.Host, options ...Option) (*IpfsDHT, error)
// handle providers
dht.proc.AddChild(dht.ProviderManager.Process())

dht.proc.Go(dht.populatePeers)

// go-routine to make sure we ALWAYS have RT peer addresses in the peerstore
// since RT membership is decoupled from connectivity
go dht.persistRTPeersInPeerStore()

dht.proc.Go(dht.rtPeerLoop)

// Fill routing table with currently connected peers that are DHT servers
dht.plk.Lock()
for _, p := range dht.host.Network().Peers() {
dht.peerFound(dht.ctx, p, false)
}
dht.plk.Unlock()

dht.proc.Go(dht.populatePeers)

return dht, nil
}

Expand Down
7 changes: 0 additions & 7 deletions subscriber_notifee.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ func newSubscriberNotifiee(dht *IpfsDHT) (*subscriberNotifee, error) {
// register for network notifications
dht.host.Network().Notify(nn)

// Fill routing table with currently connected peers that are DHT servers
dht.plk.Lock()
defer dht.plk.Unlock()
for _, p := range dht.host.Network().Peers() {
dht.peerFound(dht.ctx, p, false)
}

return nn, nil
}

Expand Down

0 comments on commit 33ec247

Please sign in to comment.