use crate::core::stratum;
use crate::rest::Error;
use std::sync::Arc;
pub struct Stratum {
stratum_ip_pool: Arc<stratum::connections::StratumIpPool>,
}
impl Stratum {
pub fn new(stratum_ip_pool: Arc<stratum::connections::StratumIpPool>) -> Self {
Stratum { stratum_ip_pool }
}
pub fn get_ip_list(
&self,
banned: Option<bool>,
) -> Result<Vec<stratum::connections::StratumIpPrintable>, Error> {
let mut get_banned = true;
let mut get_active = true;
if banned.is_some() {
get_banned = banned.unwrap();
get_active = !get_banned;
}
Ok(self.stratum_ip_pool.get_ip_list(get_banned, get_active))
}
pub fn clean_ip(&self, ip: &String) -> Result<(), Error> {
self.stratum_ip_pool.clean_ip(ip);
Ok(())
}
pub fn get_ip_info(
&self,
ip: &String,
) -> Result<stratum::connections::StratumIpPrintable, Error> {
Ok(self.stratum_ip_pool.get_ip_info(ip))
}
}