diff --git a/src/disk.rs b/src/disk.rs index f741e3a..562b64f 100644 --- a/src/disk.rs +++ b/src/disk.rs @@ -349,6 +349,10 @@ impl Node { vec![("Local Monero Node".to_string(), Self::localhost())] } + pub fn new_tuple() -> (String, Self) { + ("Local Monero Node".to_string(), Self::localhost()) + } + // Convert [String] to [Node] Vec pub fn from_str_to_vec(string: &str) -> Result, TomlError> { let nodes: toml::map::Map = match toml::de::from_str(string) { @@ -483,6 +487,10 @@ impl Pool { vec![("Local P2Pool".to_string(), Self::p2pool())] } + pub fn new_tuple() -> (String, Self) { + ("Local P2Pool".to_string(), Self::p2pool()) + } + pub fn from_str_to_vec(string: &str) -> Result, TomlError> { let pools: toml::map::Map = match toml::de::from_str(string) { Ok(map) => { diff --git a/src/main.rs b/src/main.rs index 3660eac..adc478c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -421,8 +421,11 @@ impl App { // Handle [node_vec] overflow info!("App Init | Handling [node_vec] overflow"); if og.p2pool.selected_index > app.og_node_vec.len() { - warn!("App | Overflowing manual node index [{} > {}], resetting to 1", og.p2pool.selected_index, app.og_node_vec.len()); - let (name, node) = app.og_node_vec[0].clone(); + warn!("App | Overflowing manual node index [{} > {}]", og.p2pool.selected_index, app.og_node_vec.len()); + let (name, node) = match app.og_node_vec.get(0) { + Some(zero) => zero.clone(), + None => Node::new_tuple(), + }; og.p2pool.selected_index = 0; og.p2pool.selected_name = name.clone(); og.p2pool.selected_ip = node.ip.clone(); @@ -438,7 +441,10 @@ impl App { info!("App Init | Handling [pool_vec] overflow..."); if og.xmrig.selected_index > app.og_pool_vec.len() { warn!("App | Overflowing manual pool index [{} > {}], resetting to 1", og.xmrig.selected_index, app.og_pool_vec.len()); - let (name, pool) = app.og_pool_vec[0].clone(); + let (name, pool) = match app.og_pool_vec.get(0) { + Some(zero) => zero.clone(), + None => Pool::new_tuple(), + }; og.xmrig.selected_index = 0; og.xmrig.selected_name = name.clone(); og.xmrig.selected_ip = pool.ip.clone();