diff --git a/config/defaults.go b/config/defaults.go index 40e0a6dc8..d0baf05ee 100644 --- a/config/defaults.go +++ b/config/defaults.go @@ -42,6 +42,7 @@ func DefaultConfig(home, chainId string) *NodeConfig { BootstrapRetryTime: 30 * time.Second, ListenAddress: DefaultListenAddress, BootstrapNodes: "", + AdvertisingEnabled: true, }, } diff --git a/config/p2p.go b/config/p2p.go index f679aeddc..e3d3bd6a7 100644 --- a/config/p2p.go +++ b/config/p2p.go @@ -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 diff --git a/config/toml.go b/config/toml.go index 88dea5582..ca00aae86 100644 --- a/config/toml.go +++ b/config/toml.go @@ -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: diff --git a/p2p/client.go b/p2p/client.go index 29feda4c0..0474b98ad 100644 --- a/p2p/client.go +++ b/p2p/client.go @@ -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)