packages/hyprspace: EnableAutoRelay -> EnableAutoRelayWithPeerSource

This commit is contained in:
Max Headroom 2023-10-22 14:26:50 +02:00
parent 7994f822c4
commit c9594f1121

View file

@ -133,10 +133,8 @@ func CreateNode(ctx context.Context, inputKey []byte, port int, handler network.
libp2p.EnableHolePunching(), libp2p.EnableHolePunching(),
libp2p.EnableRelayService(relay.WithLimit(nil), relay.WithACL(acl)), libp2p.EnableRelayService(relay.WithLimit(nil), relay.WithACL(acl)),
libp2p.EnableNATService(), libp2p.EnableNATService(),
libp2p.EnableAutoRelay( libp2p.EnableAutoRelayWithPeerSource(
autorelay.WithNumRelays(2), func(ctx context.Context, numPeers int) <-chan peer.AddrInfo {
autorelay.WithBootDelay(10*time.Second),
autorelay.WithPeerSource(func(ctx context.Context, numPeers int) <-chan peer.AddrInfo {
r := make(chan peer.AddrInfo) r := make(chan peer.AddrInfo)
go func() { go func() {
defer close(r) defer close(r)
@ -157,7 +155,9 @@ func CreateNode(ctx context.Context, inputKey []byte, port int, handler network.
} }
}() }()
return r return r
}), },
autorelay.WithNumRelays(2),
autorelay.WithBootDelay(10*time.Second),
), ),
libp2p.WithDialTimeout(time.Second*5), libp2p.WithDialTimeout(time.Second*5),
libp2p.FallbackDefaults, libp2p.FallbackDefaults,