mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
Update Rust Edition to 2024 (#7766)
* #7749 Thanks @dknopik and @michaelsproul for your help!
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//! Simple logic for spawning a Lighthouse BootNode.
|
||||
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use clap_utils::{get_color_style, FLAG_HEADER};
|
||||
use clap_utils::{FLAG_HEADER, get_color_style};
|
||||
|
||||
// TODO: Add DOS prevention CLI params
|
||||
pub fn cli_app() -> Command {
|
||||
|
||||
@@ -2,10 +2,11 @@ use beacon_node::{get_data_dir, set_network_config};
|
||||
use bytes::Bytes;
|
||||
use clap::ArgMatches;
|
||||
use eth2_network_config::Eth2NetworkConfig;
|
||||
use lighthouse_network::discv5::{self, enr::CombinedKey, Enr};
|
||||
use lighthouse_network::discv5::{self, Enr, enr::CombinedKey};
|
||||
use lighthouse_network::{
|
||||
CombinedKeyExt, NetworkConfig,
|
||||
discovery::{load_enr_from_disk, use_or_load_enr},
|
||||
load_private_key, CombinedKeyExt, NetworkConfig,
|
||||
load_private_key,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ssz::Encode;
|
||||
@@ -56,26 +57,30 @@ impl<E: EthSpec> BootNodeConfig<E> {
|
||||
set_network_config(&mut network_config, matches, &data_dir)?;
|
||||
|
||||
// Set the Enr Discovery ports to the listening ports if not present.
|
||||
if let Some(listening_addr_v4) = network_config.listen_addrs().v4() {
|
||||
if network_config.enr_udp4_port.is_none() {
|
||||
network_config.enr_udp4_port =
|
||||
Some(network_config.enr_udp4_port.unwrap_or(
|
||||
listening_addr_v4.disc_port.try_into().map_err(|_| {
|
||||
"boot node enr-udp-port not set and listening port is zero"
|
||||
})?,
|
||||
))
|
||||
}
|
||||
if let Some(listening_addr_v4) = network_config.listen_addrs().v4()
|
||||
&& network_config.enr_udp4_port.is_none()
|
||||
{
|
||||
network_config.enr_udp4_port = Some(
|
||||
network_config.enr_udp4_port.unwrap_or(
|
||||
listening_addr_v4
|
||||
.disc_port
|
||||
.try_into()
|
||||
.map_err(|_| "boot node enr-udp-port not set and listening port is zero")?,
|
||||
),
|
||||
)
|
||||
};
|
||||
|
||||
if let Some(listening_addr_v6) = network_config.listen_addrs().v6() {
|
||||
if network_config.enr_udp6_port.is_none() {
|
||||
network_config.enr_udp6_port =
|
||||
Some(network_config.enr_udp6_port.unwrap_or(
|
||||
listening_addr_v6.disc_port.try_into().map_err(|_| {
|
||||
"boot node enr-udp-port not set and listening port is zero"
|
||||
})?,
|
||||
))
|
||||
}
|
||||
if let Some(listening_addr_v6) = network_config.listen_addrs().v6()
|
||||
&& network_config.enr_udp6_port.is_none()
|
||||
{
|
||||
network_config.enr_udp6_port = Some(
|
||||
network_config.enr_udp6_port.unwrap_or(
|
||||
listening_addr_v6
|
||||
.disc_port
|
||||
.try_into()
|
||||
.map_err(|_| "boot node enr-udp-port not set and listening port is zero")?,
|
||||
),
|
||||
)
|
||||
};
|
||||
|
||||
// By default this is enabled. If it is not set, revert to false.
|
||||
|
||||
@@ -5,8 +5,8 @@ use crate::config::BootNodeConfigSerialization;
|
||||
use clap::ArgMatches;
|
||||
use eth2_network_config::Eth2NetworkConfig;
|
||||
use lighthouse_network::{
|
||||
discv5::{self, enr::NodeId, Discv5},
|
||||
EnrExt, Eth2Enr,
|
||||
discv5::{self, Discv5, enr::NodeId},
|
||||
};
|
||||
use tracing::{info, warn};
|
||||
use types::EthSpec;
|
||||
@@ -77,10 +77,10 @@ pub async fn run<E: EthSpec>(
|
||||
node_id = ?enr.node_id(),
|
||||
"Adding bootnode"
|
||||
);
|
||||
if enr != local_enr {
|
||||
if let Err(e) = discv5.add_enr(enr) {
|
||||
warn!(error = ?e, "Failed adding ENR");
|
||||
}
|
||||
if enr != local_enr
|
||||
&& let Err(e) = discv5.add_enr(enr)
|
||||
{
|
||||
warn!(error = ?e, "Failed adding ENR");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user