Skip to content

Commit

Permalink
Update config with extra relays (#209)
Browse files Browse the repository at this point in the history
Update defaults with extra relays and adjust autorelay settings.

Co-authored-by: ehsan shariati <[email protected]>
  • Loading branch information
masih and ehsan6sha authored Dec 29, 2023
1 parent 5a10a07 commit 5188d21
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
16 changes: 14 additions & 2 deletions cmd/blox/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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))
Expand Down
20 changes: 17 additions & 3 deletions mobile/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"io"
"time"

"github.com/functionland/go-fula/blockchain"
"github.com/functionland/go-fula/exchange"
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5188d21

Please sign in to comment.