mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-11-17 07:47:35 +00:00
Status Submenu: update hashrate dominance with [Manual] hashrate
The % dominance stats now update along with the manual hashrate. The updating UI blocks were also moved so all the updating stats are close to each other.
This commit is contained in:
parent
f97935d1e8
commit
830ee9ebcd
3 changed files with 67 additions and 26 deletions
|
@ -1249,6 +1249,8 @@ pub struct PubP2poolApi {
|
|||
pub user_p2pool_hashrate_u64: u64,
|
||||
pub p2pool_difficulty_u64: u64,
|
||||
pub monero_difficulty_u64: u64,
|
||||
pub p2pool_hashrate_u64: u64,
|
||||
pub monero_hashrate_u64: u64,
|
||||
// Tick. Every loop this gets incremented.
|
||||
// At 60, it indicated we should read the below API files.
|
||||
pub tick: u8,
|
||||
|
@ -1302,6 +1304,8 @@ impl PubP2poolApi {
|
|||
user_p2pool_hashrate_u64: 0,
|
||||
p2pool_difficulty_u64: 0,
|
||||
monero_difficulty_u64: 0,
|
||||
p2pool_hashrate_u64: 0,
|
||||
monero_hashrate_u64: 0,
|
||||
monero_difficulty: HumanNumber::unknown(),
|
||||
monero_hashrate: HumanNumber::unknown(),
|
||||
hash: String::from("???"),
|
||||
|
@ -1439,8 +1443,8 @@ impl PubP2poolApi {
|
|||
user_p2pool_percent = HumanNumber::unknown();
|
||||
} else {
|
||||
p2pool_block_mean = HumanTime::into_human(std::time::Duration::from_secs(monero_difficulty / p2pool_hashrate));
|
||||
let f = (user_hashrate as f32 / p2pool_hashrate as f32) * 100.0;
|
||||
user_p2pool_percent = HumanNumber::to_percent_no_fmt(f);
|
||||
let f = (user_hashrate as f64 / p2pool_hashrate as f64) * 100.0;
|
||||
user_p2pool_percent = HumanNumber::from_f64_to_percent_6_point(f);
|
||||
};
|
||||
let p2pool_percent;
|
||||
let user_monero_percent;
|
||||
|
@ -1448,10 +1452,10 @@ impl PubP2poolApi {
|
|||
p2pool_percent = HumanNumber::unknown();
|
||||
user_monero_percent = HumanNumber::unknown();
|
||||
} else {
|
||||
let f = (p2pool_hashrate as f32 / monero_hashrate as f32) * 100.0;
|
||||
p2pool_percent = HumanNumber::to_percent_no_fmt(f);
|
||||
let f = (user_hashrate as f32 / monero_hashrate as f32) * 100.0;
|
||||
user_monero_percent = HumanNumber::to_percent_no_fmt(f);
|
||||
let f = (p2pool_hashrate as f64 / monero_hashrate as f64) * 100.0;
|
||||
p2pool_percent = HumanNumber::from_f64_to_percent_6_point(f);
|
||||
let f = (user_hashrate as f64 / monero_hashrate as f64) * 100.0;
|
||||
user_monero_percent = HumanNumber::from_f64_to_percent_6_point(f);
|
||||
};
|
||||
let solo_block_mean;
|
||||
let p2pool_share_mean;
|
||||
|
@ -1466,6 +1470,8 @@ impl PubP2poolApi {
|
|||
*public = Self {
|
||||
p2pool_difficulty_u64: p2pool_difficulty,
|
||||
monero_difficulty_u64: monero_difficulty,
|
||||
p2pool_hashrate_u64: p2pool_hashrate,
|
||||
monero_hashrate_u64: monero_hashrate,
|
||||
monero_difficulty: HumanNumber::from_u64(monero_difficulty),
|
||||
monero_hashrate: HumanNumber::from_u64_to_gigahash_3_point(monero_hashrate),
|
||||
hash: net.hash,
|
||||
|
@ -1492,6 +1498,15 @@ impl PubP2poolApi {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn calculate_dominance(my_hashrate: u64, global_hashrate: u64) -> HumanNumber {
|
||||
if global_hashrate == 0 {
|
||||
HumanNumber::unknown()
|
||||
} else {
|
||||
let f = (my_hashrate as f64 / global_hashrate as f64) * 100.0;
|
||||
HumanNumber::from_f64_to_percent_6_point(f)
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn calculate_tick_bar(&self) -> &'static str {
|
||||
// The stars are reduced by one because it takes a frame to render the stats.
|
||||
// We want 0 stars at the same time stats are rendered, so it looks a little off here.
|
||||
|
|
12
src/human.rs
12
src/human.rs
|
@ -129,6 +129,18 @@ impl HumanNumber {
|
|||
pub fn to_percent_no_fmt(f: f32) -> Self {
|
||||
Self(format!("{}%", f))
|
||||
}
|
||||
pub fn from_f64_to_percent_3_point(f: f64) -> Self {
|
||||
Self(format!("{:.3}%", f))
|
||||
}
|
||||
pub fn from_f64_to_percent_6_point(f: f64) -> Self {
|
||||
Self(format!("{:.6}%", f))
|
||||
}
|
||||
pub fn from_f64_to_percent_9_point(f: f64) -> Self {
|
||||
Self(format!("{:.9}%", f))
|
||||
}
|
||||
pub fn from_f64_to_percent_no_fmt(f: f64) -> Self {
|
||||
Self(format!("{}%", f))
|
||||
}
|
||||
pub fn from_f32(f: f32) -> Self {
|
||||
let mut buf = num_format::Buffer::new();
|
||||
buf.write_formatted(&(f as u64), &LOCALE);
|
||||
|
|
|
@ -203,13 +203,24 @@ pub fn show(&mut self, sys: &Arc<Mutex<Sys>>, p2pool_api: &Arc<Mutex<PubP2poolAp
|
|||
let min_height = ui.available_height()/1.35;
|
||||
let api = lock!(p2pool_api);
|
||||
ui.horizontal(|ui| {
|
||||
ui.group(|ui| { ui.vertical(|ui| {
|
||||
ui.set_min_height(min_height);
|
||||
ui.add_sized([width, text], Label::new(RichText::new("Monero Difficulty").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_MONERO_DIFFICULTY);
|
||||
ui.add_sized([width, text], Label::new(api.monero_difficulty.as_str()));
|
||||
ui.add_sized([width, text], Label::new(RichText::new("Monero Hashrate").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_MONERO_HASHRATE);
|
||||
ui.add_sized([width, text], Label::new(api.monero_hashrate.as_str()));
|
||||
ui.add_sized([width, text], Label::new(RichText::new("P2Pool Difficulty").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_P2POOL_DIFFICULTY);
|
||||
ui.add_sized([width, text], Label::new(api.p2pool_difficulty.as_str()));
|
||||
ui.add_sized([width, text], Label::new(RichText::new("P2Pool Hashrate").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_P2POOL_HASHRATE);
|
||||
ui.add_sized([width, text], Label::new(api.p2pool_hashrate.as_str()));
|
||||
})});
|
||||
ui.group(|ui| { ui.vertical(|ui| {
|
||||
ui.set_min_height(min_height);
|
||||
if self.manual_hash {
|
||||
let hashrate = Hash::convert_to_hash(self.hashrate, self.hash_metric) as u64;
|
||||
let p2pool_share_mean = PubP2poolApi::calculate_share_or_block_time(hashrate, api.p2pool_difficulty_u64);
|
||||
let solo_block_mean = PubP2poolApi::calculate_share_or_block_time(hashrate, api.monero_difficulty_u64);
|
||||
ui.add_sized([width, text], Label::new(RichText::new("Your P2Pool Hashrate").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_YOUR_P2POOL_HASHRATE);
|
||||
ui.add_sized([width, text], Label::new(RichText::new("Manually Inputted Hashrate").underline().color(BONE)));
|
||||
ui.add_sized([width, text], Label::new(format!("{} H/s", HumanNumber::from_u64(hashrate))));
|
||||
ui.add_sized([width, text], Label::new(RichText::new("P2Pool Block Mean").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_P2POOL_BLOCK_MEAN);
|
||||
ui.add_sized([width, text], Label::new(api.p2pool_block_mean.to_string()));
|
||||
|
@ -230,17 +241,19 @@ pub fn show(&mut self, sys: &Arc<Mutex<Sys>>, p2pool_api: &Arc<Mutex<PubP2poolAp
|
|||
})});
|
||||
ui.group(|ui| { ui.vertical(|ui| {
|
||||
ui.set_min_height(min_height);
|
||||
ui.add_sized([width, text], Label::new(RichText::new("Monero Difficulty").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_MONERO_DIFFICULTY);
|
||||
ui.add_sized([width, text], Label::new(api.monero_difficulty.as_str()));
|
||||
ui.add_sized([width, text], Label::new(RichText::new("Monero Hashrate").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_MONERO_HASHRATE);
|
||||
ui.add_sized([width, text], Label::new(api.monero_hashrate.as_str()));
|
||||
ui.add_sized([width, text], Label::new(RichText::new("P2Pool Difficulty").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_P2POOL_DIFFICULTY);
|
||||
ui.add_sized([width, text], Label::new(api.p2pool_difficulty.as_str()));
|
||||
ui.add_sized([width, text], Label::new(RichText::new("P2Pool Hashrate").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_P2POOL_HASHRATE);
|
||||
ui.add_sized([width, text], Label::new(api.p2pool_hashrate.as_str()));
|
||||
})});
|
||||
ui.group(|ui| { ui.vertical(|ui| {
|
||||
ui.set_min_height(min_height);
|
||||
if self.manual_hash {
|
||||
let hashrate = Hash::convert_to_hash(self.hashrate, self.hash_metric) as u64;
|
||||
let user_p2pool_percent = PubP2poolApi::calculate_dominance(hashrate, api.p2pool_hashrate_u64);
|
||||
let user_monero_percent = PubP2poolApi::calculate_dominance(hashrate, api.monero_hashrate_u64);
|
||||
ui.add_sized([width, text], Label::new(RichText::new("P2Pool Miners").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_P2POOL_MINERS);
|
||||
ui.add_sized([width, text], Label::new(api.miners.as_str()));
|
||||
ui.add_sized([width, text], Label::new(RichText::new("P2Pool Dominance").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_P2POOL_DOMINANCE);
|
||||
ui.add_sized([width, text], Label::new(api.p2pool_percent.as_str()));
|
||||
ui.add_sized([width, text], Label::new(RichText::new("Your P2Pool Dominance").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_YOUR_P2POOL_DOMINANCE);
|
||||
ui.add_sized([width, text], Label::new(user_p2pool_percent.as_str()));
|
||||
ui.add_sized([width, text], Label::new(RichText::new("Your Monero Dominance").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_YOUR_MONERO_DOMINANCE);
|
||||
ui.add_sized([width, text], Label::new(user_monero_percent.as_str()));
|
||||
} else {
|
||||
ui.add_sized([width, text], Label::new(RichText::new("P2Pool Miners").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_P2POOL_MINERS);
|
||||
ui.add_sized([width, text], Label::new(api.miners.as_str()));
|
||||
ui.add_sized([width, text], Label::new(RichText::new("P2Pool Dominance").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_P2POOL_DOMINANCE);
|
||||
|
@ -249,6 +262,7 @@ pub fn show(&mut self, sys: &Arc<Mutex<Sys>>, p2pool_api: &Arc<Mutex<PubP2poolAp
|
|||
ui.add_sized([width, text], Label::new(api.user_p2pool_percent.as_str()));
|
||||
ui.add_sized([width, text], Label::new(RichText::new("Your Monero Dominance").underline().color(BONE))).on_hover_text(STATUS_SUBMENU_YOUR_MONERO_DOMINANCE);
|
||||
ui.add_sized([width, text], Label::new(api.user_monero_percent.as_str()));
|
||||
}
|
||||
})});
|
||||
});
|
||||
// Tick bar
|
||||
|
|
Loading…
Reference in a new issue