Skip to content

Commit

Permalink
Merge branch 'master' into whitelist-connection-gater
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Oct 28, 2024
2 parents 983cfc9 + f8b548c commit fe47d25
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions p2p/communication.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,19 @@ func (c *Communication) startChannel(privKeyBytes []byte) error {
routingDiscovery := discovery_routing.NewRoutingDiscovery(kademliaDHT)
discovery_util.Advertise(ctx, routingDiscovery, c.rendezvous)

// Create a goroutine to shut down the DHT after 5 minutes
go func() {
select {
case <-time.After(5 * time.Minute):
c.logger.Info().Msg("Closing Kademlia DHT after 5 minutes")
if err := kademliaDHT.Close(); err != nil {
c.logger.Error().Err(err).Msg("Failed to close Kademlia DHT")
}
case <-ctx.Done():
c.logger.Info().Msg("Context done, not waiting for 5 minutes to close DHT")
}
}()

err = c.bootStrapConnectivityCheck()
if err != nil {
return err
Expand Down

0 comments on commit fe47d25

Please sign in to comment.