Fix: fix the issue of not being able to specify bootnode through command parameters (#9237)

This commit is contained in:
令狐一冲
2024-07-04 23:38:09 +08:00
committed by GitHub
parent a6430d48fd
commit ed203356c6

View File

@ -123,6 +123,12 @@ impl NetworkArgs {
///
/// The `default_peers_file` will be used as the default location to store the persistent peers
/// file if `no_persist_peers` is false, and there is no provided `peers_file`.
///
/// Configured Bootnodes are prioritized, if unset, the chain spec bootnodes are used
/// Priority order for bootnodes configuration:
/// 1. --bootnodes flag
/// 2. Network preset flags (e.g. --holesky)
/// 3. default to mainnet nodes
pub fn network_config(
&self,
config: &Config,
@ -130,7 +136,16 @@ impl NetworkArgs {
secret_key: SecretKey,
default_peers_file: PathBuf,
) -> NetworkConfigBuilder {
let chain_bootnodes = chain_spec.bootnodes().unwrap_or_else(mainnet_nodes);
let chain_bootnodes = self
.bootnodes
.clone()
.map(|bootnodes| {
bootnodes
.into_iter()
.filter_map(|trusted_peer| trusted_peer.resolve_blocking().ok())
.collect()
})
.unwrap_or_else(|| chain_spec.bootnodes().unwrap_or_else(mainnet_nodes));
let peers_file = self.peers_file.clone().unwrap_or(default_peers_file);
// Configure peer connections