Procházet zdrojové kódy

chore: add tiemout to findpeers (#569)

Signed-off-by: mudler <[email protected]>
Ettore Di Giacinto před 1 rokem
rodič
revize
418f7c6855
1 změnil soubory, kde provedl 3 přidání a 1 odebrání
  1. 3 1
      pkg/discovery/dht.go

+ 3 - 1
pkg/discovery/dht.go

@@ -234,7 +234,9 @@ func (d *DHT) announceAndConnect(l log.StandardLogger, ctx context.Context, kade
 	// This is like your friend telling you the location to meet you.
 	l.Debug("Searching for other peers...")
 
-	peerChan, err := routingDiscovery.FindPeers(ctx, rv)
+	fCtx, cf := context.WithTimeout(ctx, time.Second*120)
+	defer cf()
+	peerChan, err := routingDiscovery.FindPeers(fCtx, rv)
 	if err != nil {
 		return err
 	}