Skip to content

Commit 93b7a4e

Browse files
committed
feat: refactor algorithm
- easier to understand/better separation of logic - more features available
1 parent 53ed4ec commit 93b7a4e

File tree

20 files changed

+1162
-1514
lines changed

20 files changed

+1162
-1514
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ listeners = "0.3"
9999
notify-rust = "4.11"
100100
## handle Ctrl+C for daemon mode
101101
ctrlc = {version="3.5", features=["termination"]}
102+
103+
tokio-stream = {version = "0.1", default-features=false}
104+
thiserror = "2.0"
102105
# Unix dependencies
103106
[target.'cfg(unix)'.dependencies]
104107
tar = "0.4.44"

src/app/mod.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use crate::helper::xrig::xmrig::PubXmrigApi;
4646
use crate::helper::xrig::xmrig_proxy::ImgProxy;
4747
use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
4848
use crate::helper::xvb::PubXvbApi;
49-
use crate::helper::xvb::priv_stats::RuntimeMode;
49+
use crate::helper::xvb::algorithm::XvbMode;
5050
use crate::inits::init_text_styles;
5151
use crate::miscs::cmp_f64;
5252
use crate::miscs::get_exe;
@@ -712,24 +712,14 @@ impl App {
712712
// Set saved prefer local node to runtime
713713
app.p2pool_api.lock().unwrap().prefer_local_node = app.state.p2pool.prefer_local_node;
714714

715-
// Set saved choice of use of sidechain HR
716-
app.xvb_api.lock().unwrap().use_p2pool_sidechain_hr = app.state.xvb.use_p2pool_sidechain_hr;
717-
718715
// Set saved choice for notifications
719716
app.notifications_api.lock().unwrap().notifications = app.state.gupax.notifications.clone();
720717

721-
// Set saved Hero mode to runtime.
718+
// Set saved XvB settings to XvB API
719+
// Need to save to pub as we read it as instant data
722720
debug!("Setting runtime_mode & runtime_manual_amount");
723-
// apply hero if simple mode saved with checkbox true, will let default to auto otherwise
724-
if app.state.xvb.simple {
725-
if app.state.xvb.simple_hero_mode {
726-
app.xvb_api.lock().unwrap().stats_priv.runtime_mode = RuntimeMode::Hero
727-
}
728-
} else {
729-
app.xvb_api.lock().unwrap().stats_priv.runtime_mode = app.state.xvb.mode.clone().into();
730-
}
731-
app.xvb_api.lock().unwrap().stats_priv.runtime_manual_amount =
732-
app.state.xvb.manual_amount_raw;
721+
app.xvb_api.lock().unwrap().algo_config = app.state.xvb.algo_config.clone();
722+
app.xvb_api.lock().unwrap().runtime_mode = XvbMode::from(&app.state.xvb);
733723

734724
drop(og); // Unlock [og]
735725

src/app/panels/bottom.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::disk::node::Node;
77
use crate::disk::pool::Pool;
88
use crate::disk::state::{Gupax, GupaxTheme, State};
99
use crate::helper::node::{CheckLocalOutsideNode, spawn_local_outside_checker};
10+
use crate::helper::xvb::algorithm::XvbMode;
1011
use crate::helper::{Helper, ProcessName, ProcessSignal, ProcessState};
1112
use crate::utils::constants::*;
1213
use crate::utils::errors::{ErrorButtons, ErrorFerris};
@@ -531,7 +532,7 @@ impl crate::app::App {
531532
);
532533
}
533534
fn xvb_submenu(&mut self, ui: &mut Ui) {
534-
Self::simple_advanced_submenu(ui, &mut self.state.xvb.simple, (XVB_SIMPLE, XVB_ADVANCED));
535+
self.simple_advanced_submenu_xvb(ui, (XVB_SIMPLE, XVB_ADVANCED));
535536
}
536537
fn status_submenu(state_submenu: &mut SubmenuStatus, ui: &mut Ui) {
537538
ui.group(|ui| {
@@ -582,6 +583,38 @@ impl crate::app::App {
582583
});
583584
}
584585

586+
fn simple_advanced_submenu_xvb(&mut self, ui: &mut Ui, hover_text: (&str, &str)) {
587+
let spacing = spacing(ui);
588+
let width = ((ui.available_width() - spacing) / 4.0).max(0.0);
589+
590+
ui.group(|ui| {
591+
if ui
592+
.add_sized(
593+
[width, ui.available_height()],
594+
Button::selectable(self.state.xvb.simple, "Simple"),
595+
)
596+
// .selectable_label(*value, "Simple")
597+
.on_hover_text(hover_text.0)
598+
.clicked()
599+
{
600+
self.state.xvb.simple = true;
601+
self.xvb_api.lock().unwrap().runtime_mode = XvbMode::from(&self.state.xvb);
602+
}
603+
ui.separator();
604+
if ui
605+
.add_sized(
606+
[width, ui.available_height()],
607+
Button::selectable(!self.state.xvb.simple, "Advanced"),
608+
)
609+
// .selectable_label(*value, "Advanced")
610+
.on_hover_text(hover_text.1)
611+
.clicked()
612+
{
613+
self.state.xvb.simple = false;
614+
self.xvb_api.lock().unwrap().runtime_mode = XvbMode::from(&self.state.xvb);
615+
}
616+
});
617+
}
585618
fn simple_advanced_submenu(ui: &mut Ui, simple: &mut bool, hover_text: (&str, &str)) {
586619
let spacing = spacing(ui);
587620
let width = ((ui.available_width() - spacing) / 4.0).max(0.0);

src/app/panels/middle/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ impl crate::app::App {
158158
ctx,
159159
ui,
160160
&self.xvb_api,
161-
&self.xmrig_api,
162-
&self.xmrig_proxy_api,
163161
states.is_alive(ProcessName::Xvb),
164162
);
165163
}

0 commit comments

Comments
 (0)