mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2025-04-16 11:41:56 +00:00
fix: xmrig process making UI lag
This commit is contained in:
parent
0606cdf7aa
commit
642901b835
7 changed files with 61 additions and 59 deletions
src
|
@ -7,9 +7,7 @@ use crate::{
|
|||
app::panels::middle::common::list_poolnode::PoolNode,
|
||||
components::node::RemoteNode,
|
||||
disk::status::*,
|
||||
helper::{
|
||||
Helper, Process, ProcessName, node::ImgNode, p2pool::ImgP2pool, xrig::xmrig_proxy::ImgProxy,
|
||||
},
|
||||
helper::{Helper, ProcessName, node::ImgNode, p2pool::ImgP2pool, xrig::xmrig_proxy::ImgProxy},
|
||||
};
|
||||
//---------------------------------------------------------------------------------------------------- [State] Impl
|
||||
impl Default for State {
|
||||
|
@ -768,9 +766,8 @@ impl Node {
|
|||
(rpc_port, zmq_port)
|
||||
}
|
||||
/// get the ports that the node process is currently using or that it will use if started with current settings
|
||||
pub fn current_ports(&self, node_process: &Process, img_node: &ImgNode) -> (u16, u16) {
|
||||
let node_is_alive = node_process.is_alive();
|
||||
if node_is_alive {
|
||||
pub fn current_ports(&self, alive: bool, img_node: &ImgNode) -> (u16, u16) {
|
||||
if alive {
|
||||
(img_node.zmq_port, img_node.rpc_port)
|
||||
} else {
|
||||
self.ports()
|
||||
|
@ -824,9 +821,8 @@ impl P2pool {
|
|||
}
|
||||
|
||||
/// get the ports that the node process is currently using or that it will use if started with current settings
|
||||
pub fn current_port(&self, p2pool_process: &Process, img_p2pool: &ImgP2pool) -> u16 {
|
||||
let p2pool_is_alive = p2pool_process.is_alive();
|
||||
if p2pool_is_alive {
|
||||
pub fn current_port(&self, alive: bool, img_p2pool: &ImgP2pool) -> u16 {
|
||||
if alive {
|
||||
img_p2pool.stratum_port
|
||||
} else {
|
||||
self.stratum_port()
|
||||
|
@ -889,9 +885,8 @@ impl XmrigProxy {
|
|||
}
|
||||
/// get the port that proxy process is currently using or that it will use if started with current settings
|
||||
/// return (bind port, api port)
|
||||
pub fn current_ports(&self, proxy_process: &Process, img_proxy: &ImgProxy) -> (u16, u16) {
|
||||
let proxy_is_alive = proxy_process.is_alive();
|
||||
if proxy_is_alive {
|
||||
pub fn current_ports(&self, alive: bool, img_proxy: &ImgProxy) -> (u16, u16) {
|
||||
if alive {
|
||||
(img_proxy.port, img_proxy.api_port)
|
||||
} else {
|
||||
(self.bind_port(), self.api_port())
|
||||
|
|
|
@ -253,8 +253,10 @@ impl Helper {
|
|||
// the user will need to restart p2pool
|
||||
let node_process = Arc::clone(&helper.lock().unwrap().node);
|
||||
let img_node = Arc::clone(&helper.lock().unwrap().img_node);
|
||||
let (local_node_zmq, local_node_rpc) =
|
||||
state_node.current_ports(&node_process.lock().unwrap(), &img_node.lock().unwrap());
|
||||
let (local_node_zmq, local_node_rpc) = state_node.current_ports(
|
||||
node_process.lock().unwrap().is_alive(),
|
||||
&img_node.lock().unwrap(),
|
||||
);
|
||||
let args = Self::build_p2pool_args(
|
||||
state,
|
||||
path,
|
||||
|
|
|
@ -89,7 +89,7 @@ impl Helper {
|
|||
// if xmrig stop, xvb will react in any case.
|
||||
if current_pool
|
||||
!= Pool::P2pool(p2pool_state.current_port(
|
||||
&process_p2pool.lock().unwrap(),
|
||||
process_p2pool.lock().unwrap().is_alive(),
|
||||
&p2pool_img.lock().unwrap(),
|
||||
))
|
||||
{
|
||||
|
@ -106,10 +106,13 @@ impl Helper {
|
|||
let pool = detect_pool_xmrig(
|
||||
&line,
|
||||
proxy_state
|
||||
.current_ports(&process_xp.lock().unwrap(), &proxy_img.lock().unwrap())
|
||||
.current_ports(
|
||||
process_xp.lock().unwrap().is_alive(),
|
||||
&proxy_img.lock().unwrap(),
|
||||
)
|
||||
.0,
|
||||
p2pool_state.current_port(
|
||||
&process_p2pool.lock().unwrap(),
|
||||
process_p2pool.lock().unwrap().is_alive(),
|
||||
&p2pool_img.lock().unwrap(),
|
||||
),
|
||||
);
|
||||
|
@ -239,8 +242,10 @@ impl Helper {
|
|||
let process_p2pool = Arc::clone(&helper.lock().unwrap().p2pool);
|
||||
let p2pool_img = Arc::clone(&helper.lock().unwrap().img_p2pool);
|
||||
|
||||
let p2pool_stratum_port =
|
||||
p2pool_state.current_port(&process_p2pool.lock().unwrap(), &p2pool_img.lock().unwrap());
|
||||
let p2pool_stratum_port = p2pool_state.current_port(
|
||||
process_p2pool.lock().unwrap().is_alive(),
|
||||
&p2pool_img.lock().unwrap(),
|
||||
);
|
||||
helper.lock().unwrap().xmrig.lock().unwrap().state = ProcessState::Middle;
|
||||
let api_ip_port = Self::mutate_img_xmrig(helper, state, p2pool_stratum_port);
|
||||
let mode = if state.simple {
|
||||
|
@ -681,24 +686,24 @@ impl Helper {
|
|||
// if mining on proxy and proxy is not alive, switch back to p2pool node
|
||||
debug!("update from priv ok");
|
||||
// unlock first process_xp and then pub_api
|
||||
let process_p2pool_lock = &process_p2pool.lock().unwrap();
|
||||
let process_xp_lock = &process_xp.lock().unwrap();
|
||||
let pub_api_lock = pub_api.lock().unwrap();
|
||||
if (pub_api_lock.pool
|
||||
let p2pool_alive = process_p2pool.lock().unwrap().is_alive().to_owned();
|
||||
let xp_alive = process_xp.lock().unwrap().is_alive().to_owned();
|
||||
let xmrig_pool = pub_api.lock().unwrap().pool.to_owned();
|
||||
if (xmrig_pool
|
||||
== Some(Pool::XmrigProxy(
|
||||
proxy_state
|
||||
.current_ports(process_xp_lock, &proxy_img.lock().unwrap())
|
||||
.current_ports(xp_alive, &proxy_img.lock().unwrap())
|
||||
.0,
|
||||
))
|
||||
|| pub_api_lock.pool.is_none())
|
||||
&& !process_xp_lock.is_alive()
|
||||
&& process_p2pool_lock.is_alive()
|
||||
|| xmrig_pool.is_none())
|
||||
&& !xp_alive
|
||||
&& p2pool_alive
|
||||
{
|
||||
info!(
|
||||
"XMRig Process | redirect xmrig to p2pool since XMRig-Proxy is not alive and p2pool is alive"
|
||||
);
|
||||
let pool = Pool::P2pool(
|
||||
p2pool_state.current_port(process_p2pool_lock, &p2pool_img.lock().unwrap()),
|
||||
p2pool_state.current_port(p2pool_alive, &p2pool_img.lock().unwrap()),
|
||||
);
|
||||
if let Err(err) = update_xmrig_config(
|
||||
&client,
|
||||
|
@ -920,9 +925,9 @@ impl PubXmrigApi {
|
|||
if let Some(name_pool) = crate::regex::detect_pool_xmrig(
|
||||
&output_parse,
|
||||
proxy_state
|
||||
.current_ports(process_proxy, &proxy_img.lock().unwrap())
|
||||
.current_ports(process_proxy.is_alive(), &proxy_img.lock().unwrap())
|
||||
.0,
|
||||
p2pool_state.current_port(process_p2pool, &p2pool_img.lock().unwrap()),
|
||||
p2pool_state.current_port(process_p2pool.is_alive(), &p2pool_img.lock().unwrap()),
|
||||
) {
|
||||
public.pool = Some(name_pool);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ impl Helper {
|
|||
);
|
||||
if current_node
|
||||
!= Pool::P2pool(p2pool_state.current_port(
|
||||
&process_p2pool.lock().unwrap(),
|
||||
process_p2pool.lock().unwrap().is_alive(),
|
||||
&p2pool_img.lock().unwrap(),
|
||||
))
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ impl Helper {
|
|||
&line,
|
||||
proxy_state.bind_port(),
|
||||
p2pool_state.current_port(
|
||||
&process_p2pool.lock().unwrap(),
|
||||
process_p2pool.lock().unwrap().is_alive(),
|
||||
&p2pool_img.lock().unwrap(),
|
||||
),
|
||||
);
|
||||
|
@ -340,8 +340,10 @@ impl Helper {
|
|||
// get the stratum port of p2pool
|
||||
let process_p2pool = Arc::clone(&helper.lock().unwrap().p2pool);
|
||||
let p2pool_img = Arc::clone(&helper.lock().unwrap().img_p2pool);
|
||||
let p2pool_stratum_port =
|
||||
state_p2pool.current_port(&process_p2pool.lock().unwrap(), &p2pool_img.lock().unwrap());
|
||||
let p2pool_stratum_port = state_p2pool.current_port(
|
||||
process_p2pool.lock().unwrap().is_alive(),
|
||||
&p2pool_img.lock().unwrap(),
|
||||
);
|
||||
// store the data used for startup to make it available to the other processes.
|
||||
Helper::mutate_img_proxy(helper, state_proxy);
|
||||
let args = Self::build_xp_args(state_proxy, mode, p2pool_stratum_port);
|
||||
|
@ -682,7 +684,7 @@ impl PubXmrigProxyApi {
|
|||
if let Some(name_pool) = detect_pool_xmrig(
|
||||
&output_parse,
|
||||
state.bind_port(),
|
||||
p2pool_state.current_port(process_p2pool, &p2pool_img.lock().unwrap()),
|
||||
p2pool_state.current_port(process_p2pool.is_alive(), &p2pool_img.lock().unwrap()),
|
||||
) {
|
||||
public.pool = Some(name_pool);
|
||||
}
|
||||
|
|
|
@ -296,7 +296,7 @@ impl<'a> Algorithm<'a> {
|
|||
|
||||
async fn target_p2pool_node(&self) {
|
||||
let node = Pool::P2pool(self.state_p2pool.current_port(
|
||||
&self.p2pool_process.lock().unwrap(),
|
||||
self.p2pool_process.lock().unwrap().is_alive(),
|
||||
&self.p2pool_img.lock().unwrap(),
|
||||
));
|
||||
if self.gui_api_xvb.lock().unwrap().current_pool != Some(node.clone()) {
|
||||
|
@ -352,7 +352,7 @@ impl<'a> Algorithm<'a> {
|
|||
.as_ref()
|
||||
.is_some_and(|n| {
|
||||
n == &Pool::P2pool(self.state_p2pool.current_port(
|
||||
&self.p2pool_process.lock().unwrap(),
|
||||
self.p2pool_process.lock().unwrap().is_alive(),
|
||||
&self.p2pool_img.lock().unwrap(),
|
||||
))
|
||||
})
|
||||
|
|
|
@ -632,7 +632,7 @@ async fn check_state_outcauses_xvb(
|
|||
// only update xmrig if it is alive and wasn't on p2pool already.
|
||||
if gui_api.lock().unwrap().current_pool
|
||||
!= Some(Pool::P2pool(state_p2pool.current_port(
|
||||
&process_p2pool.lock().unwrap(),
|
||||
process_p2pool.lock().unwrap().is_alive(),
|
||||
&p2pool_img.lock().unwrap(),
|
||||
)))
|
||||
&& (process_xmrig.lock().unwrap().state == ProcessState::Alive || xp_is_alive)
|
||||
|
@ -657,7 +657,7 @@ async fn check_state_outcauses_xvb(
|
|||
current_api_url_xrig(true, Some(&xmrig_img.lock().unwrap()), None)
|
||||
};
|
||||
let pool = Pool::P2pool(state_p2pool.current_port(
|
||||
&process_p2pool.lock().unwrap(),
|
||||
process_p2pool.lock().unwrap().is_alive(),
|
||||
&p2pool_img.lock().unwrap(),
|
||||
));
|
||||
if let Err(err) = update_xmrig_config(
|
||||
|
@ -682,7 +682,7 @@ async fn check_state_outcauses_xvb(
|
|||
} else {
|
||||
let pool =
|
||||
Pool::P2pool(state_p2pool.current_port(
|
||||
&process_p2pool.lock().unwrap(),
|
||||
process_p2pool.lock().unwrap().is_alive(),
|
||||
&p2pool_img.lock().unwrap(),
|
||||
));
|
||||
output_console(
|
||||
|
@ -861,7 +861,7 @@ fn signal_interrupt(
|
|||
// but if xmrig didn't start, don't update it.
|
||||
|
||||
let p2pool_pool = Pool::P2pool(state_p2pool.current_port(
|
||||
&process_p2pool.lock().unwrap(),
|
||||
process_p2pool.lock().unwrap().is_alive(),
|
||||
&p2pool_img.lock().unwrap(),
|
||||
));
|
||||
if process_xrig.lock().unwrap().state == ProcessState::Alive && gui_api.lock().unwrap().current_pool != Some(p2pool_pool.clone()) {
|
||||
|
|
|
@ -134,32 +134,30 @@ impl Pool {
|
|||
Pool::XvBEurope
|
||||
} else {
|
||||
// if P2pool is returned, it means none of the two nodes are available.
|
||||
Pool::P2pool(
|
||||
p2pool_state.current_port(
|
||||
&process_p2pool.lock().unwrap(),
|
||||
&p2pool_img.lock().unwrap(),
|
||||
),
|
||||
)
|
||||
Pool::P2pool(p2pool_state.current_port(
|
||||
process_p2pool.lock().unwrap().is_alive(),
|
||||
&p2pool_img.lock().unwrap(),
|
||||
))
|
||||
}
|
||||
} else {
|
||||
error!("ping has failed !");
|
||||
Pool::P2pool(
|
||||
p2pool_state
|
||||
.current_port(&process_p2pool.lock().unwrap(), &p2pool_img.lock().unwrap()),
|
||||
)
|
||||
Pool::P2pool(p2pool_state.current_port(
|
||||
process_p2pool.lock().unwrap().is_alive(),
|
||||
&p2pool_img.lock().unwrap(),
|
||||
))
|
||||
}
|
||||
} else {
|
||||
error!("ping has failed !");
|
||||
Pool::P2pool(
|
||||
p2pool_state
|
||||
.current_port(&process_p2pool.lock().unwrap(), &p2pool_img.lock().unwrap()),
|
||||
)
|
||||
Pool::P2pool(p2pool_state.current_port(
|
||||
process_p2pool.lock().unwrap().is_alive(),
|
||||
&p2pool_img.lock().unwrap(),
|
||||
))
|
||||
};
|
||||
if pool
|
||||
== Pool::P2pool(
|
||||
p2pool_state
|
||||
.current_port(&process_p2pool.lock().unwrap(), &p2pool_img.lock().unwrap()),
|
||||
)
|
||||
== Pool::P2pool(p2pool_state.current_port(
|
||||
process_p2pool.lock().unwrap().is_alive(),
|
||||
&p2pool_img.lock().unwrap(),
|
||||
))
|
||||
{
|
||||
// if both nodes are dead, then the state of the process must be NodesOffline
|
||||
info!("XvB node ping, all offline or ping failed, switching back to local p2pool",);
|
||||
|
|
Loading…
Reference in a new issue