node: fix node name max length

This commit is contained in:
hinto.janai 2023-03-17 16:11:22 -04:00
parent c388f53cd1
commit 4058aa0f8f
No known key found for this signature in database
GPG key ID: D47CE05FA175A499

View file

@ -62,7 +62,7 @@ pub const REMOTE_NODES: [(&str, &str, &str, &str); 24] = [
]; ];
pub const REMOTE_NODE_LENGTH: usize = REMOTE_NODES.len(); pub const REMOTE_NODE_LENGTH: usize = REMOTE_NODES.len();
pub const REMOTE_NODE_MAX_CHARS: usize = 25; // node-01-xmr.godevs.cloud pub const REMOTE_NODE_MAX_CHARS: usize = 28; // xmr.aa78i2efsewr0neeknk.xyz
pub struct RemoteNode { pub struct RemoteNode {
pub ip: &'static str, pub ip: &'static str,
@ -215,35 +215,8 @@ pub fn format_ip_location(og_ip: &str, extra_space: bool) -> String {
"??? | ???".to_string() "??? | ???".to_string()
} }
// node-01-xmr.godevs.cloud = 25 max length
pub fn format_ip(ip: &str) -> String { pub fn format_ip(ip: &str) -> String {
match ip.len() { format!("{: >28}", ip)
1 => format!("{} ", ip),
2 => format!("{} ", ip),
3 => format!("{} ", ip),
4 => format!("{} ", ip),
5 => format!("{} ", ip),
6 => format!("{} ", ip),
7 => format!("{} ", ip),
8 => format!("{} ", ip),
9 => format!("{} ", ip),
10 => format!("{} ", ip),
11 => format!("{} ", ip),
12 => format!("{} ", ip),
13 => format!("{} ", ip),
14 => format!("{} ", ip),
15 => format!("{} ", ip),
16 => format!("{} ", ip),
17 => format!("{} ", ip),
18 => format!("{} ", ip),
19 => format!("{} ", ip),
20 => format!("{} ", ip),
21 => format!("{} ", ip),
22 => format!("{} ", ip),
23 => format!("{} ", ip),
24 => format!("{} ", ip),
_ => format!("{}", ip),
}
} }
//---------------------------------------------------------------------------------------------------- Node data //---------------------------------------------------------------------------------------------------- Node data
@ -445,7 +418,7 @@ mod test {
#[test] #[test]
fn spacing() { fn spacing() {
for (ip, _, _, _) in crate::REMOTE_NODES { for (ip, _, _, _) in crate::REMOTE_NODES {
assert!(crate::format_ip(ip).len() <= crate::REMOTE_NODE_MAX_CHARS); assert!(crate::format_ip(ip).len() == crate::REMOTE_NODE_MAX_CHARS);
} }
} }