diff --git a/dht.go b/dht.go index 26429728a..df5a43148 100644 --- a/dht.go +++ b/dht.go @@ -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 } diff --git a/subscriber_notifee.go b/subscriber_notifee.go index 75e9cbe83..8211d25de 100644 --- a/subscriber_notifee.go +++ b/subscriber_notifee.go @@ -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 }