mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-12-22 14:49:21 +00:00
feat: use local node by default for p2pool simple tab
This commit is contained in:
parent
1a16db6a5b
commit
59a9c0defe
2 changed files with 141 additions and 123 deletions
|
@ -33,10 +33,20 @@ impl P2pool {
|
||||||
// Two atomic bools = enough to represent this data
|
// Two atomic bools = enough to represent this data
|
||||||
|
|
||||||
// local or remote
|
// local or remote
|
||||||
|
// button bool
|
||||||
|
ui.vertical_centered(|ui|{
|
||||||
|
ui.add_space(space_h);
|
||||||
|
ui.checkbox(&mut self.local_node, "Use a local node").on_hover_text("If checked (recommended), p2pool will automatically use the local node.\nCheck the Node tab to start a local node.\nIf unchecked, p2pool will attempt to use a remote node.");
|
||||||
|
});
|
||||||
|
ui.add_space(space_h * 2.0);
|
||||||
|
|
||||||
|
// if checked, use only local node
|
||||||
|
// if unchecked, show remote nodes.
|
||||||
|
|
||||||
// disable remote if local is checked.
|
// disable remote if local is checked.
|
||||||
|
let visible = !self.local_node;
|
||||||
debug!("P2Pool Tab | Running [auto-select] check");
|
debug!("P2Pool Tab | Running [auto-select] check");
|
||||||
if self.auto_select {
|
if self.auto_select && visible {
|
||||||
let mut ping = lock!(ping);
|
let mut ping = lock!(ping);
|
||||||
// If we haven't auto_selected yet, auto-select and turn it off
|
// If we haven't auto_selected yet, auto-select and turn it off
|
||||||
if ping.pinged && !ping.auto_selected {
|
if ping.pinged && !ping.auto_selected {
|
||||||
|
@ -46,142 +56,147 @@ impl P2pool {
|
||||||
drop(ping);
|
drop(ping);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.vertical(|ui| {
|
ui.add_enabled_ui(visible, |ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.vertical(|ui| {
|
||||||
debug!("P2Pool Tab | Rendering [Ping List]");
|
ui.horizontal(|ui| {
|
||||||
// [Ping List]
|
debug!("P2Pool Tab | Rendering [Ping List]");
|
||||||
let mut ms = 0;
|
// [Ping List]
|
||||||
let mut color = Color32::LIGHT_GRAY;
|
let mut ms = 0;
|
||||||
if lock!(ping).pinged {
|
let mut color = Color32::LIGHT_GRAY;
|
||||||
for data in lock!(ping).nodes.iter() {
|
if lock!(ping).pinged {
|
||||||
if data.ip == self.node {
|
for data in lock!(ping).nodes.iter() {
|
||||||
ms = data.ms;
|
if data.ip == self.node {
|
||||||
color = data.color;
|
ms = data.ms;
|
||||||
break;
|
color = data.color;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
debug!("P2Pool Tab | Rendering [ComboBox] of Remote Nodes");
|
||||||
debug!("P2Pool Tab | Rendering [ComboBox] of Remote Nodes");
|
let ip_location = format_ip_location(&self.node, false);
|
||||||
let ip_location = format_ip_location(&self.node, false);
|
let text = RichText::new(format!(" ⏺ {}ms | {}", ms, ip_location)).color(color);
|
||||||
let text = RichText::new(format!(" ⏺ {}ms | {}", ms, ip_location)).color(color);
|
ComboBox::from_id_salt("remote_nodes")
|
||||||
ComboBox::from_id_salt("remote_nodes")
|
.selected_text(text)
|
||||||
.selected_text(text)
|
.width(size.x)
|
||||||
.width(size.x)
|
.show_ui(ui, |ui| {
|
||||||
.show_ui(ui, |ui| {
|
for data in lock!(ping).nodes.iter() {
|
||||||
for data in lock!(ping).nodes.iter() {
|
let ms = format_ms(data.ms);
|
||||||
let ms = format_ms(data.ms);
|
let ip_location = format_ip_location(data.ip, true);
|
||||||
let ip_location = format_ip_location(data.ip, true);
|
let text = RichText::new(format!(" ⏺ {} | {}", ms, ip_location))
|
||||||
let text = RichText::new(format!(" ⏺ {} | {}", ms, ip_location))
|
.color(data.color);
|
||||||
.color(data.color);
|
ui.selectable_value(&mut self.node, data.ip.to_string(), text);
|
||||||
ui.selectable_value(&mut self.node, data.ip.to_string(), text);
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
ui.add_space(space_h);
|
ui.add_space(space_h);
|
||||||
|
|
||||||
debug!("P2Pool Tab | Rendering [Select fastest ... Ping] buttons");
|
debug!("P2Pool Tab | Rendering [Select fastest ... Ping] buttons");
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
let width = ((size.x / 5.0) - 6.0).max(0.0);
|
let width = ((size.x / 5.0) - 6.0).max(0.0);
|
||||||
let size = vec2(width, height);
|
let size = vec2(width, height);
|
||||||
// [Select random node]
|
// [Select random node]
|
||||||
if ui
|
|
||||||
.add_sized(size, Button::new("Select random node"))
|
|
||||||
.on_hover_text(P2POOL_SELECT_RANDOM)
|
|
||||||
.clicked()
|
|
||||||
{
|
|
||||||
self.node = RemoteNode::get_random(&self.node);
|
|
||||||
}
|
|
||||||
// [Select fastest node]
|
|
||||||
if ui
|
|
||||||
.add_sized(size, Button::new("Select fastest node"))
|
|
||||||
.on_hover_text(P2POOL_SELECT_FASTEST)
|
|
||||||
.clicked()
|
|
||||||
&& lock!(ping).pinged
|
|
||||||
{
|
|
||||||
self.node = lock!(ping).fastest.to_string();
|
|
||||||
}
|
|
||||||
// [Ping Button]
|
|
||||||
ui.add_enabled_ui(!lock!(ping).pinging, |ui| {
|
|
||||||
if ui
|
if ui
|
||||||
.add_sized(size, Button::new("Ping remote nodes"))
|
.add_sized(size, Button::new("Select random node"))
|
||||||
.on_hover_text(P2POOL_PING)
|
.on_hover_text(P2POOL_SELECT_RANDOM)
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
Ping::spawn_thread(ping);
|
self.node = RemoteNode::get_random(&self.node);
|
||||||
|
}
|
||||||
|
// [Select fastest node]
|
||||||
|
if ui
|
||||||
|
.add_sized(size, Button::new("Select fastest node"))
|
||||||
|
.on_hover_text(P2POOL_SELECT_FASTEST)
|
||||||
|
.clicked()
|
||||||
|
&& lock!(ping).pinged
|
||||||
|
{
|
||||||
|
self.node = lock!(ping).fastest.to_string();
|
||||||
|
}
|
||||||
|
// [Ping Button]
|
||||||
|
ui.add_enabled_ui(!lock!(ping).pinging, |ui| {
|
||||||
|
if ui
|
||||||
|
.add_sized(size, Button::new("Ping remote nodes"))
|
||||||
|
.on_hover_text(P2POOL_PING)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
Ping::spawn_thread(ping);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// [Last <-]
|
||||||
|
if ui
|
||||||
|
.add_sized(size, Button::new("⬅ Last"))
|
||||||
|
.on_hover_text(P2POOL_SELECT_LAST)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
let ping = lock!(ping);
|
||||||
|
match ping.pinged {
|
||||||
|
true => {
|
||||||
|
self.node = RemoteNode::get_last_from_ping(&self.node, &ping.nodes)
|
||||||
|
}
|
||||||
|
false => self.node = RemoteNode::get_last(&self.node),
|
||||||
|
}
|
||||||
|
drop(ping);
|
||||||
|
}
|
||||||
|
// [Next ->]
|
||||||
|
if ui
|
||||||
|
.add_sized(size, Button::new("Next ➡"))
|
||||||
|
.on_hover_text(P2POOL_SELECT_NEXT)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
let ping = lock!(ping);
|
||||||
|
match ping.pinged {
|
||||||
|
true => {
|
||||||
|
self.node = RemoteNode::get_next_from_ping(&self.node, &ping.nodes)
|
||||||
|
}
|
||||||
|
false => self.node = RemoteNode::get_next(&self.node),
|
||||||
|
}
|
||||||
|
drop(ping);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// [Last <-]
|
|
||||||
if ui
|
|
||||||
.add_sized(size, Button::new("⬅ Last"))
|
|
||||||
.on_hover_text(P2POOL_SELECT_LAST)
|
|
||||||
.clicked()
|
|
||||||
{
|
|
||||||
let ping = lock!(ping);
|
|
||||||
match ping.pinged {
|
|
||||||
true => self.node = RemoteNode::get_last_from_ping(&self.node, &ping.nodes),
|
|
||||||
false => self.node = RemoteNode::get_last(&self.node),
|
|
||||||
}
|
|
||||||
drop(ping);
|
|
||||||
}
|
|
||||||
// [Next ->]
|
|
||||||
if ui
|
|
||||||
.add_sized(size, Button::new("Next ➡"))
|
|
||||||
.on_hover_text(P2POOL_SELECT_NEXT)
|
|
||||||
.clicked()
|
|
||||||
{
|
|
||||||
let ping = lock!(ping);
|
|
||||||
match ping.pinged {
|
|
||||||
true => self.node = RemoteNode::get_next_from_ping(&self.node, &ping.nodes),
|
|
||||||
false => self.node = RemoteNode::get_next(&self.node),
|
|
||||||
}
|
|
||||||
drop(ping);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
let height = height / 2.0;
|
let height = height / 2.0;
|
||||||
let pinging = lock!(ping).pinging;
|
let pinging = lock!(ping).pinging;
|
||||||
ui.add_enabled_ui(pinging, |ui| {
|
ui.add_enabled_ui(pinging, |ui| {
|
||||||
let prog = lock!(ping).prog.round();
|
let prog = lock!(ping).prog.round();
|
||||||
let msg = RichText::new(format!("{} ... {}%", lock!(ping).msg, prog));
|
let msg = RichText::new(format!("{} ... {}%", lock!(ping).msg, prog));
|
||||||
let height = height / 1.25;
|
let height = height / 1.25;
|
||||||
let size = vec2(size.x, height);
|
let size = vec2(size.x, height);
|
||||||
ui.add_space(space_h);
|
ui.add_space(space_h);
|
||||||
ui.add_sized(size, Label::new(msg));
|
ui.add_sized(size, Label::new(msg));
|
||||||
ui.add_space(space_h);
|
ui.add_space(space_h);
|
||||||
if pinging {
|
if pinging {
|
||||||
ui.add_sized(size, Spinner::new().size(height));
|
ui.add_sized(size, Spinner::new().size(height));
|
||||||
} else {
|
} else {
|
||||||
ui.add_sized(size, Label::new("..."));
|
ui.add_sized(size, Label::new("..."));
|
||||||
}
|
}
|
||||||
ui.add_sized(size, ProgressBar::new(prog.round() / 100.0));
|
ui.add_sized(size, ProgressBar::new(prog.round() / 100.0));
|
||||||
ui.add_space(space_h);
|
ui.add_space(space_h);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
debug!("P2Pool Tab | Rendering [Auto-*] buttons");
|
debug!("P2Pool Tab | Rendering [Auto-*] buttons");
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
let width = ((size.x / 3.0) - (SPACE * 1.75)).max(0.0);
|
let width = ((size.x / 3.0) - (SPACE * 1.75)).max(0.0);
|
||||||
let size = vec2(width, height);
|
let size = vec2(width, height);
|
||||||
// [Auto-node]
|
// [Auto-node]
|
||||||
ui.add_sized(size, Checkbox::new(&mut self.auto_select, "Auto-select"))
|
ui.add_sized(size, Checkbox::new(&mut self.auto_select, "Auto-select"))
|
||||||
.on_hover_text(P2POOL_AUTO_SELECT);
|
.on_hover_text(P2POOL_AUTO_SELECT);
|
||||||
ui.separator();
|
ui.separator();
|
||||||
// [Auto-node]
|
// [Auto-node]
|
||||||
ui.add_sized(size, Checkbox::new(&mut self.auto_ping, "Auto-ping"))
|
ui.add_sized(size, Checkbox::new(&mut self.auto_ping, "Auto-ping"))
|
||||||
.on_hover_text(P2POOL_AUTO_NODE);
|
.on_hover_text(P2POOL_AUTO_NODE);
|
||||||
ui.separator();
|
ui.separator();
|
||||||
// [Backup host]
|
// [Backup host]
|
||||||
ui.add_sized(size, Checkbox::new(&mut self.backup_host, "Backup host"))
|
ui.add_sized(size, Checkbox::new(&mut self.backup_host, "Backup host"))
|
||||||
.on_hover_text(P2POOL_BACKUP_HOST_SIMPLE);
|
.on_hover_text(P2POOL_BACKUP_HOST_SIMPLE);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
debug!("P2Pool Tab | Rendering warning text");
|
debug!("P2Pool Tab | Rendering warning text");
|
||||||
ui.add_sized(
|
ui.add_sized(
|
||||||
[size.x, height / 2.0],
|
[size.x, height / 2.0],
|
||||||
Hyperlink::from_label_and_url(
|
Hyperlink::from_label_and_url(
|
||||||
"WARNING: It is recommended to run/use your own Monero Node (hover for details)",
|
"WARNING: It is recommended to run/use your own Monero Node (hover for details)",
|
||||||
|
@ -189,5 +204,6 @@ impl P2pool {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.on_hover_text(P2POOL_COMMUNITY_NODE_WARNING);
|
.on_hover_text(P2POOL_COMMUNITY_NODE_WARNING);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,6 +209,7 @@ pub struct Gupax {
|
||||||
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
|
||||||
pub struct P2pool {
|
pub struct P2pool {
|
||||||
pub simple: bool,
|
pub simple: bool,
|
||||||
|
pub local_node: bool,
|
||||||
pub mini: bool,
|
pub mini: bool,
|
||||||
pub auto_ping: bool,
|
pub auto_ping: bool,
|
||||||
pub auto_select: bool,
|
pub auto_select: bool,
|
||||||
|
@ -487,6 +488,7 @@ impl Default for P2pool {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
simple: true,
|
simple: true,
|
||||||
|
local_node: true,
|
||||||
mini: true,
|
mini: true,
|
||||||
auto_ping: true,
|
auto_ping: true,
|
||||||
auto_select: true,
|
auto_select: true,
|
||||||
|
|
Loading…
Reference in a new issue