Prevent adding and dialing bootnodes when discovery is disabled (#2247)

This is a small PR which prevents unwanted bootnodes from being added to the DHT and being dialed when the `--disable-discovery` flag is set. 

The main reason one would want to disable discovery is to connect to a fix set of peers. Currently, regardless of what the user does, Lighthouse will populate its DHT with previously known peers and also fill it with the spec's bootnodes. It will then dial the bootnodes that are capable of being dialed. This prevents testing with a fixed peer list.

This PR prevents these excess nodes from being added and dialed if the user has set `--disable-discovery`.
This commit is contained in:
Age Manning
2021-03-08 06:27:49 +00:00
parent 8faab89f09
commit babd153352
3 changed files with 81 additions and 94 deletions

View File

@@ -259,8 +259,11 @@ pub fn get_config<E: EthSpec>(
"address" => &client_config.eth1.deposit_contract_address
);
if let Some(mut boot_nodes) = eth2_network_config.boot_enr {
client_config.network.boot_nodes_enr.append(&mut boot_nodes)
// Only append network config bootnodes if discovery is not disabled
if !client_config.network.disable_discovery {
if let Some(mut boot_nodes) = eth2_network_config.boot_enr {
client_config.network.boot_nodes_enr.append(&mut boot_nodes)
}
}
if let Some(genesis_state_bytes) = eth2_network_config.genesis_state_bytes {