Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(p2p): add p2p advertising option #862

Merged
merged 11 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func DefaultConfig(home, chainId string) *NodeConfig {
BootstrapRetryTime: 30 * time.Second,
ListenAddress: DefaultListenAddress,
BootstrapNodes: "",
AdvertisingEnabled: true,
},
}

Expand Down
2 changes: 2 additions & 0 deletions config/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type P2PConfig struct {
GossipedBlocksCacheSize int `mapstructure:"p2p_gossiped_blocks_cache_size"`
// Time interval a node tries to bootstrap again, in case no nodes connected
BootstrapRetryTime time.Duration `mapstructure:"p2p_bootstrap_retry_time"`
// Param used to enable the advertisement of the node to be part of the P2P network in the DHT
AdvertisingEnabled bool `mapstructure:"p2p_advertising_enabled"`
}

// Validate P2PConfig
Expand Down
3 changes: 3 additions & 0 deletions config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ p2p_gossiped_blocks_cache_size = {{ .P2PConfig.GossipedBlocksCacheSize }}
# time interval to check if no p2p nodes are connected to bootstrap again
p2p_bootstrap_retry_time = "{{ .P2PConfig.BootstrapRetryTime }}"

# set to false to disable advertising the node to the P2P network
p2p_advertising_enabled= "{{ .P2PConfig.AdvertisingEnabled }}"

#celestia config example:
# da_config = "{\"base_url\":\"http:\/\/127.0.0.1:26658\",\"timeout\":5000000000,\"gas_prices\":0.1,\"auth_token\":\"TOKEN\",\"backoff\":{\"initial_delay\":6000000000,\"max_delay\":6000000000,\"growth_factor\":2},\"retry_attempts\":4,\"retry_delay\":3000000000}"
# Avail config example:
Expand Down
8 changes: 5 additions & 3 deletions p2p/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,11 @@ func (c *Client) peerDiscovery(ctx context.Context) error {
return err
}

err = c.advertise(ctx)
if err != nil {
return err
if c.conf.AdvertisingEnabled {
err = c.advertise(ctx)
if err != nil {
return err
}
}

err = c.findPeers(ctx)
Expand Down
Loading