mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2025-01-03 12:39:35 +00:00
fix: XvB process start perf
fix: create client in thread instead of before it
This commit is contained in:
parent
89ef45a5ac
commit
66417b3b0b
1 changed files with 28 additions and 44 deletions
|
@ -71,8 +71,6 @@ impl Helper {
|
||||||
let process_p2pool = Arc::clone(&lock!(helper).p2pool);
|
let process_p2pool = Arc::clone(&lock!(helper).p2pool);
|
||||||
let gui_api_p2pool = Arc::clone(&lock!(helper).gui_api_p2pool);
|
let gui_api_p2pool = Arc::clone(&lock!(helper).gui_api_p2pool);
|
||||||
info!("XvB | cloning of state");
|
info!("XvB | cloning of state");
|
||||||
let state_xvb_check = state_xvb.clone();
|
|
||||||
let state_p2pool_check = state_p2pool.clone();
|
|
||||||
// Reset before printing to output.
|
// Reset before printing to output.
|
||||||
// Need to reset because values of stats would stay otherwise which could bring confusion even if panel is with a disabled theme.
|
// Need to reset because values of stats would stay otherwise which could bring confusion even if panel is with a disabled theme.
|
||||||
info!("XvB | resetting pub and gui");
|
info!("XvB | resetting pub and gui");
|
||||||
|
@ -87,22 +85,36 @@ impl Helper {
|
||||||
lock.start = Instant::now();
|
lock.start = Instant::now();
|
||||||
}
|
}
|
||||||
// verify if token and address are existent on XvB server
|
// verify if token and address are existent on XvB server
|
||||||
|
let state_xvb = state_xvb.clone();
|
||||||
|
let state_p2pool = state_p2pool.clone();
|
||||||
|
|
||||||
info!("XvB | rt runtime");
|
info!("XvB | spawn watchdog");
|
||||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
thread::spawn(move || {
|
||||||
info!("XvB | client");
|
Self::spawn_xvb_watchdog(
|
||||||
let https = HttpsConnector::new();
|
gui_api,
|
||||||
let client = Arc::new(hyper::Client::builder().build(https));
|
pub_api,
|
||||||
let client_test = client.clone();
|
process,
|
||||||
let resp: anyhow::Result<()> = rt.block_on(async move {
|
&state_xvb,
|
||||||
XvbPrivStats::request_api(
|
&state_p2pool,
|
||||||
&client_test,
|
gui_api_p2pool,
|
||||||
&state_p2pool_check.address,
|
process_p2pool,
|
||||||
&state_xvb_check.token,
|
);
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
Ok(())
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
#[tokio::main]
|
||||||
|
async fn spawn_xvb_watchdog(
|
||||||
|
gui_api: Arc<Mutex<PubXvbApi>>,
|
||||||
|
pub_api: Arc<Mutex<PubXvbApi>>,
|
||||||
|
process: Arc<Mutex<Process>>,
|
||||||
|
state_xvb: &crate::disk::state::Xvb,
|
||||||
|
state_p2pool: &crate::disk::state::P2pool,
|
||||||
|
gui_api_p2pool: Arc<Mutex<PubP2poolApi>>,
|
||||||
|
process_p2pool: Arc<Mutex<Process>>,
|
||||||
|
) {
|
||||||
|
let https = HttpsConnector::new();
|
||||||
|
let client = hyper::Client::builder().build(https);
|
||||||
|
let resp =
|
||||||
|
XvbPrivStats::request_api(&client, &state_p2pool.address, &state_xvb.token).await;
|
||||||
info!("XvB | verify address and token");
|
info!("XvB | verify address and token");
|
||||||
match resp {
|
match resp {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
@ -149,34 +161,6 @@ impl Helper {
|
||||||
error!("XvB Watchdog | GUI status write failed: {}", e);
|
error!("XvB Watchdog | GUI status write failed: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info!("XvB | clone state for thread");
|
|
||||||
let state_xvb_thread = state_xvb.clone();
|
|
||||||
let state_p2pool_thread = state_p2pool.clone();
|
|
||||||
info!("XvB | spawn watchdog");
|
|
||||||
thread::spawn(move || {
|
|
||||||
Self::spawn_xvb_watchdog(
|
|
||||||
client,
|
|
||||||
gui_api,
|
|
||||||
pub_api,
|
|
||||||
process,
|
|
||||||
&state_xvb_thread,
|
|
||||||
&state_p2pool_thread,
|
|
||||||
gui_api_p2pool,
|
|
||||||
process_p2pool,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
#[tokio::main]
|
|
||||||
async fn spawn_xvb_watchdog(
|
|
||||||
client: Arc<hyper::Client<HttpsConnector<HttpConnector>>>,
|
|
||||||
gui_api: Arc<Mutex<PubXvbApi>>,
|
|
||||||
pub_api: Arc<Mutex<PubXvbApi>>,
|
|
||||||
process: Arc<Mutex<Process>>,
|
|
||||||
state_xvb: &crate::disk::state::Xvb,
|
|
||||||
state_p2pool: &crate::disk::state::P2pool,
|
|
||||||
gui_api_p2pool: Arc<Mutex<PubP2poolApi>>,
|
|
||||||
process_p2pool: Arc<Mutex<Process>>,
|
|
||||||
) {
|
|
||||||
// see how many shares are found at p2pool node only if XvB is started successfully. If it wasn't, maybe P2pool is node not running.
|
// see how many shares are found at p2pool node only if XvB is started successfully. If it wasn't, maybe P2pool is node not running.
|
||||||
let mut old_shares = if lock!(process).state == ProcessState::Alive {
|
let mut old_shares = if lock!(process).state == ProcessState::Alive {
|
||||||
// a loop until the value is some to let p2pool work and get first value.
|
// a loop until the value is some to let p2pool work and get first value.
|
||||||
|
|
Loading…
Reference in a new issue