From 5188d2107a35b45c486e9acea9faed4446a8a69a Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Fri, 29 Dec 2023 18:47:54 +0000 Subject: [PATCH] Update config with extra relays (#209) Update defaults with extra relays and adjust autorelay settings. Co-authored-by: ehsan shariati --- cmd/blox/main.go | 16 ++++++++++++++-- mobile/config.go | 20 +++++++++++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/cmd/blox/main.go b/cmd/blox/main.go index 33b70ae..20c3e9c 100644 --- a/cmd/blox/main.go +++ b/cmd/blox/main.go @@ -306,7 +306,14 @@ func init() { altsrc.NewStringSliceFlag(&cli.StringSliceFlag{ Name: "staticRelays", Destination: &app.config.staticRelays, - Value: cli.NewStringSlice("/dns/relay.dev.fx.land/tcp/4001/p2p/12D3KooWDRrBaAfPwsGJivBoUw5fE7ZpDiyfUjqgiURq2DEcL835"), + Value: cli.NewStringSlice( + "/dns/relay.dev.fx.land/tcp/4001/p2p/12D3KooWDRrBaAfPwsGJivBoUw5fE7ZpDiyfUjqgiURq2DEcL835", + "/dns/alpha-relay.dev.fx.land/tcp/4001/p2p/12D3KooWFLhr8j6LTF7QV1oGCn3DVNTs1eMz2u4KCDX6Hw3BFyag", + "/dns/bravo-relay.dev.fx.land/tcp/4001/p2p/12D3KooWA2JrcPi2Z6i2U8H3PLQhLYacx6Uj9MgexEsMsyX6Fno7", + "/dns/charlie-relay.dev.fx.land/tcp/4001/p2p/12D3KooWKaK6xRJwjhq6u6yy4Mw2YizyVnKxptoT9yXMn3twgYns", + "/dns/delta-relay.dev.fx.land/tcp/4001/p2p/12D3KooWDtA7kecHAGEB8XYEKHBUTt8GsRfMen1yMs7V85vrpMzC", + "/dns/echo-relay.dev.fx.land/tcp/4001/p2p/12D3KooWQBigsW1tvGmZQet8t5MLMaQnDJKXAP2JNh7d1shk2fb2", + ), }), altsrc.NewBoolFlag(&cli.BoolFlag{ Name: "forceReachabilityPrivate", @@ -685,7 +692,12 @@ func action(ctx *cli.Context) error { sr = append(sr, *rai) } if len(sr) != 0 { - hopts = append(hopts, libp2p.EnableAutoRelayWithStaticRelays(sr, autorelay.WithNumRelays(1))) + hopts = append(hopts, libp2p.EnableAutoRelayWithStaticRelays(sr, + autorelay.WithMinCandidates(1), + autorelay.WithNumRelays(1), + autorelay.WithBootDelay(30*time.Second), + autorelay.WithMinInterval(10*time.Second), + )) } bopts := append(hopts, libp2p.Identity(k)) diff --git a/mobile/config.go b/mobile/config.go index 1d20f04..91a6f8a 100644 --- a/mobile/config.go +++ b/mobile/config.go @@ -5,6 +5,7 @@ import ( "context" "errors" "io" + "time" "github.com/functionland/go-fula/blockchain" "github.com/functionland/go-fula/exchange" @@ -27,9 +28,17 @@ import ( const ( noopExchange = "noop" - devRelay = "/dns/relay.dev.fx.land/tcp/4001/p2p/12D3KooWDRrBaAfPwsGJivBoUw5fE7ZpDiyfUjqgiURq2DEcL835" ) +var devRelays = []string{ + "/dns/relay.dev.fx.land/tcp/4001/p2p/12D3KooWDRrBaAfPwsGJivBoUw5fE7ZpDiyfUjqgiURq2DEcL835", + "/dns/alpha-relay.dev.fx.land/tcp/4001/p2p/12D3KooWFLhr8j6LTF7QV1oGCn3DVNTs1eMz2u4KCDX6Hw3BFyag", + "/dns/bravo-relay.dev.fx.land/tcp/4001/p2p/12D3KooWA2JrcPi2Z6i2U8H3PLQhLYacx6Uj9MgexEsMsyX6Fno7", + "/dns/charlie-relay.dev.fx.land/tcp/4001/p2p/12D3KooWKaK6xRJwjhq6u6yy4Mw2YizyVnKxptoT9yXMn3twgYns", + "/dns/delta-relay.dev.fx.land/tcp/4001/p2p/12D3KooWDtA7kecHAGEB8XYEKHBUTt8GsRfMen1yMs7V85vrpMzC", + "/dns/echo-relay.dev.fx.land/tcp/4001/p2p/12D3KooWQBigsW1tvGmZQet8t5MLMaQnDJKXAP2JNh7d1shk2fb2", +} + type Config struct { Identity []byte StorePath string @@ -71,7 +80,7 @@ type Config struct { // NewConfig instantiates a new Config with default values. func NewConfig() *Config { return &Config{ - StaticRelays: []string{devRelay}, + StaticRelays: devRelays, ForceReachabilityPrivate: true, AllowTransientConnection: true, PoolName: "0", @@ -104,7 +113,12 @@ func (cfg *Config) init(mc *Client) error { } sr = append(sr, *rai) } - hopts = append(hopts, libp2p.EnableAutoRelayWithStaticRelays(sr, autorelay.WithNumRelays(1))) + hopts = append(hopts, libp2p.EnableAutoRelayWithStaticRelays(sr, + autorelay.WithMinCandidates(1), + autorelay.WithNumRelays(1), + autorelay.WithBootDelay(30*time.Second), + autorelay.WithMinInterval(10*time.Second), + )) } if cfg.ForceReachabilityPrivate {