Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
improve discovery on nodes
Antonio Ojeaa23e96be93b4
diff --git a/cmd/sam-node/node.go b/cmd/sam-node/node.goindex 93c8b2fa..546d0905 100644--- a/cmd/sam-node/node.go+++ b/cmd/sam-node/node.go@@ -192,11 +192,26 @@ func NewSamNode(ctx context.Context, privKey crypto.PrivKey, hubPubKey ed25519.P}),}+ authSuccess := make(chan struct{})+// If we have a Hub, configure it as our static fallback relay for NAT hole-punchingif len(staticRelays) > 0 {- opts = append(opts, libp2p.EnableAutoRelayWithStaticRelays(- staticRelays,- autorelay.WithBootDelay(2*time.Second),+ opts = append(opts, libp2p.EnableAutoRelayWithPeerSource(+ func(ctx context.Context, numPeers int) <-chan peer.AddrInfo {+ c := make(chan peer.AddrInfo, len(staticRelays))+ go func() {+ defer close(c)+ select {+ case <-ctx.Done():+ case <-authSuccess:+ for _, r := range staticRelays {+ c <- r+ }+ }+ }()+ return c+ },+ autorelay.WithBootDelay(0),autorelay.WithBackoff(3*time.Second),))}@@ -287,6 +302,10 @@ func NewSamNode(ctx context.Context, privKey crypto.PrivKey, hubPubKey ed25519.P}}+ if authenticated {+ close(authSuccess)+ }+// Initialize Gossipsub for Hub Eventsps, err := pubsub.NewGossipSub(ctx, h)if err != nil {