fix: also set configured bootnodes for discv5 (#9885)

This commit is contained in:
Matthias Seitz
2024-07-30 01:40:24 +02:00
committed by GitHub
parent 8bd5cafe9a
commit eb2d0a22d9
5 changed files with 53 additions and 17 deletions

View File

@ -118,6 +118,13 @@ pub struct NetworkArgs {
}
impl NetworkArgs {
/// Returns the resolved bootnodes if any are provided.
pub fn resolved_bootnodes(&self) -> Option<Vec<NodeRecord>> {
self.bootnodes.clone().map(|bootnodes| {
bootnodes.into_iter().filter_map(|node| node.resolve_blocking().ok()).collect()
})
}
/// Build a [`NetworkConfigBuilder`] from a [`Config`] and a [`ChainSpec`], in addition to the
/// values in this option struct.
///
@ -137,14 +144,7 @@ impl NetworkArgs {
default_peers_file: PathBuf,
) -> NetworkConfigBuilder {
let chain_bootnodes = self
.bootnodes
.clone()
.map(|bootnodes| {
bootnodes
.into_iter()
.filter_map(|trusted_peer| trusted_peer.resolve_blocking().ok())
.collect()
})
.resolved_bootnodes()
.unwrap_or_else(|| chain_spec.bootnodes().unwrap_or_else(mainnet_nodes));
let peers_file = self.peers_file.clone().unwrap_or(default_peers_file);