mirror of
https://github.com/hinto-janai/gupax.git
synced 2024-11-17 09:47:36 +00:00
node: return random instead of [0] for a default
This commit is contained in:
parent
4e87277bbd
commit
1e04bd2fa7
1 changed files with 8 additions and 8 deletions
16
src/node.rs
16
src/node.rs
|
@ -34,7 +34,7 @@ use hyper::{
|
|||
// Remote Monero Nodes with ZMQ enabled, sourced from: [https://github.com/hinto-janai/monero-nodes]
|
||||
// The format is an array of tuples consisting of: (IP, LOCATION, RPC_PORT, ZMQ_PORT)
|
||||
|
||||
pub const REMOTE_NODES: [(&str, &str, &str, &str); 23] = [
|
||||
pub const REMOTE_NODES: [(&str, &str, &str, &str); 20] = [
|
||||
("monero.10z.com.ar", "AR - Buenos Aires F.D.", "18089", "18084"),
|
||||
("monero2.10z.com.ar", "BR - São Paulo", "18089", "18083"),
|
||||
("monero1.heitechsoft.com", "CA - Ontario", "18081", "18084"),
|
||||
|
@ -75,13 +75,7 @@ impl Default for RemoteNode {
|
|||
|
||||
impl RemoteNode {
|
||||
pub fn new() -> Self {
|
||||
let (ip, location, rpc, zmq) = REMOTE_NODES[0];
|
||||
Self {
|
||||
ip,
|
||||
location,
|
||||
rpc,
|
||||
zmq,
|
||||
}
|
||||
Self::get_random_same_ok()
|
||||
}
|
||||
|
||||
pub fn check_exists(og_ip: &str) -> String {
|
||||
|
@ -140,6 +134,12 @@ impl RemoteNode {
|
|||
node.to_string()
|
||||
}
|
||||
|
||||
// Return a random valid node (no input str).
|
||||
pub fn get_random_same_ok() -> Self {
|
||||
let rng = thread_rng().gen_range(0..REMOTE_NODE_LENGTH);
|
||||
Self::from_index(rng)
|
||||
}
|
||||
|
||||
// Return the node [-1] of this one
|
||||
pub fn get_last(current_ip: &str) -> String {
|
||||
let mut found = false;
|
||||
|
|
Loading…
Reference in a new issue