Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
DaughterOfMars committed Dec 19, 2024
1 parent 2e5e436 commit e0e2326
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions crates/iota/src/validator_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
collections::{BTreeMap, HashSet},
fmt::{self, Debug, Display, Formatter, Write},
fs,
net::{Ipv4Addr, Ipv6Addr},
net::IpAddr,
path::PathBuf,
};

Expand Down Expand Up @@ -331,12 +331,10 @@ impl IotaValidatorCommand {
&authority_keypair,
(&account_keypair.public()).into(),
);
let transport_str = if host_name.parse::<Ipv4Addr>().is_ok() {
"ip4"
} else if host_name.parse::<Ipv6Addr>().is_ok() {
"ip6"
} else {
"dns"
let transport_str = match host_name.parse::<IpAddr>() {
Ok(IpAddr::V4(_)) => "ip4",
Ok(IpAddr::V6(_)) => "ip6",
Err(_) => "dns",
};
let validator_info = GenesisValidatorInfo {
info: iota_genesis_builder::validator_info::ValidatorInfo {
Expand All @@ -348,16 +346,13 @@ impl IotaValidatorCommand {
gas_price,
commission_rate: iota_config::node::DEFAULT_COMMISSION_RATE,
network_address: Multiaddr::try_from(format!(
"/{}/{}/tcp/8080/http",
transport_str, host_name
"/{transport_str}/{host_name}/tcp/8080/http",
))?,
p2p_address: Multiaddr::try_from(format!(
"/{}/{}/udp/8084",
transport_str, host_name
"/{transport_str}/{host_name}/udp/8084",
))?,
primary_address: Multiaddr::try_from(format!(
"/{}/{}/tcp/8081",
transport_str, host_name
"/{transport_str}/{host_name}/tcp/8081",
))?,
description,
image_url,
Expand All @@ -369,10 +364,7 @@ impl IotaValidatorCommand {
let validator_info_file_name = dir.join("validator.info");
let validator_info_bytes = serde_yaml::to_string(&validator_info)?;
fs::write(validator_info_file_name.clone(), validator_info_bytes)?;
println!(
"Generated validator info file: {:?}.",
validator_info_file_name
);
println!("Generated validator info file: {validator_info_file_name:?}.");
IotaValidatorCommandResponse::MakeValidatorInfo
}
IotaValidatorCommand::BecomeCandidate { file, gas_budget } => {
Expand Down

0 comments on commit e0e2326

Please sign in to comment.