mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-12-22 14:49:21 +00:00
feat: enable xmrig with remote control and token, generate token
This commit is contained in:
parent
2499953725
commit
87eb738ca8
6 changed files with 52 additions and 12 deletions
|
@ -59,7 +59,7 @@ So 1kH/s is given to XvB node so that the miner participate in the Donor round.
|
|||
P2pool node (PN) local API show only found shares and not current. It is not also showing the current height block of p2pool.
|
||||
Gupaxx process will check every minute when a new share is found, and how much time passed since the last. While verifying if mining on mini or main chain, it will calculate if the last share found is still valid.
|
||||
This way Gupaxx will know if a share is currently in the window.
|
||||
This method is only an estimation, a better way would be to know at which block the share is found and which block height the network is currently at. But P2pool API doesn't offer these informations by API but by command.
|
||||
This method is only an estimation, a better way would be to know at which block the share is found and which block height the network is currently at. But P2pool API doesn't offer these information by API but by command.
|
||||
|
||||
### Knowing the HR generated by Gupaxx
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
- [ ] distribute hashrate conforming to the algorithm.
|
||||
- [x] check every 10 minutes average Xmrig HR of last 15 minutes
|
||||
- [ ] ask Xmrig to mine on p2pool
|
||||
- [ ] generate token for xmrig
|
||||
- [ ] enable xmrig with remote access control
|
||||
- [x] generate token for xmrig
|
||||
- [x] enable xmrig with remote access control
|
||||
- [x] check if at least a share in pplns Window
|
||||
- [ ] calculate spared HR
|
||||
- [ ] calculate time to be spared
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use anyhow::{Result};
|
||||
|
||||
|
||||
|
||||
use anyhow::Result;
|
||||
use rand::{distributions::Alphanumeric, thread_rng, Rng};
|
||||
|
||||
use super::*;
|
||||
use crate::{components::node::RemoteNode, disk::status::*};
|
||||
|
@ -242,6 +240,7 @@ pub struct Xmrig {
|
|||
pub selected_rig: String,
|
||||
pub selected_ip: String,
|
||||
pub selected_port: String,
|
||||
pub token: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize, Default)]
|
||||
|
@ -363,6 +362,11 @@ impl Default for Xmrig {
|
|||
keepalive: false,
|
||||
current_threads: 1,
|
||||
max_threads: 1,
|
||||
token: thread_rng()
|
||||
.sample_iter(Alphanumeric)
|
||||
.take(16)
|
||||
.map(char::from)
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ mod test {
|
|||
selected_rig = "Gupax"
|
||||
selected_ip = "192.168.1.122"
|
||||
selected_port = "3333"
|
||||
token = "testtoken"
|
||||
|
||||
[xvb]
|
||||
token = ""
|
||||
|
|
|
@ -141,8 +141,18 @@ impl Helper {
|
|||
let gui_api = Arc::clone(&lock!(helper).gui_api_xmrig);
|
||||
let pub_api = Arc::clone(&lock!(helper).pub_api_xmrig);
|
||||
let path = path.to_path_buf();
|
||||
let token = state.token.clone();
|
||||
thread::spawn(move || {
|
||||
Self::spawn_xmrig_watchdog(process, gui_api, pub_api, args, path, sudo, api_ip_port);
|
||||
Self::spawn_xmrig_watchdog(
|
||||
process,
|
||||
gui_api,
|
||||
pub_api,
|
||||
args,
|
||||
path,
|
||||
sudo,
|
||||
api_ip_port,
|
||||
&token,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -189,6 +199,8 @@ impl Helper {
|
|||
args.push("127.0.0.1".to_string()); // HTTP API IP
|
||||
args.push("--http-port".to_string());
|
||||
args.push("18088".to_string()); // HTTP API Port
|
||||
args.push(format!("--http-access-token={}", state.token)); // HTTP API Port
|
||||
args.push("--http-no-restricted".to_string());
|
||||
if state.pause != 0 {
|
||||
args.push("--pause-on-active".to_string());
|
||||
args.push(state.pause.to_string());
|
||||
|
@ -313,6 +325,7 @@ impl Helper {
|
|||
path: std::path::PathBuf,
|
||||
sudo: Arc<Mutex<SudoState>>,
|
||||
mut api_ip_port: String,
|
||||
token: &str,
|
||||
) {
|
||||
// 1a. Create PTY
|
||||
debug!("XMRig | Creating PTY...");
|
||||
|
@ -543,10 +556,11 @@ impl Helper {
|
|||
start.elapsed(),
|
||||
&process,
|
||||
);
|
||||
|
||||
// Send an HTTP API request
|
||||
debug!("XMRig Watchdog | Attempting HTTP API request...");
|
||||
if let Ok(priv_api) = PrivXmrigApi::request_xmrig_api(client.clone(), &api_uri).await {
|
||||
if let Ok(priv_api) =
|
||||
PrivXmrigApi::request_xmrig_api(client.clone(), &api_uri, token).await
|
||||
{
|
||||
debug!("XMRig Watchdog | HTTP API request OK, attempting [update_from_priv()]");
|
||||
PubXmrigApi::update_from_priv(&pub_api, priv_api);
|
||||
} else {
|
||||
|
@ -729,9 +743,11 @@ impl PrivXmrigApi {
|
|||
async fn request_xmrig_api(
|
||||
client: hyper::Client<hyper::client::HttpConnector>,
|
||||
api_uri: &str,
|
||||
token: &str,
|
||||
) -> std::result::Result<Self, anyhow::Error> {
|
||||
let request = hyper::Request::builder()
|
||||
.method("GET")
|
||||
.header("Authorization", ["Bearer ", token].concat())
|
||||
.uri(api_uri)
|
||||
.body(hyper::Body::empty())?;
|
||||
let response = tokio::time::timeout(
|
||||
|
|
|
@ -244,9 +244,9 @@ impl Helper {
|
|||
break;
|
||||
}
|
||||
}
|
||||
debug!("XvB Watchdog | Attempting HTTP private API request...");
|
||||
// only if private API is accessible, NotMining here means that the token and address is not registered on the XvB website.
|
||||
// only if private API is accessible, NotMining here means that the token and address is not registered on the XvB website and Syncing means P2pool node is not running and so that some information for private info are not available.
|
||||
if lock!(process).state == ProcessState::Alive {
|
||||
debug!("XvB Watchdog | Attempting HTTP private API request...");
|
||||
// reload private stats
|
||||
match XvbPrivStats::request_api(
|
||||
&client,
|
||||
|
@ -328,6 +328,22 @@ impl Helper {
|
|||
{
|
||||
lock!(pub_api).stats_priv.win_current = true
|
||||
}
|
||||
// if 10 minutes passed since last check
|
||||
if lock!(gui_api).tick_distribute_hr > (60 * 10) {
|
||||
// request XMrig to mine on P2pool
|
||||
}
|
||||
// if share is in PW,
|
||||
// check average HR of last 15 minutes from XMrig.
|
||||
// if HR + buffer >= mHR,
|
||||
// calculate how much time can be spared
|
||||
// if not hero option
|
||||
// calculate how much time needed to be spared to be in most round type minimum HR + buffer
|
||||
// fi
|
||||
// sleep 10m less spared time then request XMrig to mine on XvB
|
||||
// fi
|
||||
// fi
|
||||
// instant saved for next check
|
||||
// fi
|
||||
}
|
||||
|
||||
lock!(gui_api).tick = 0;
|
||||
|
@ -356,6 +372,7 @@ pub struct PubXvbApi {
|
|||
pub output: String,
|
||||
pub uptime: u64,
|
||||
pub tick: u8,
|
||||
pub tick_distribute_hr: u16,
|
||||
pub stats_pub: XvbPubStats,
|
||||
pub stats_priv: XvbPrivStats,
|
||||
}
|
||||
|
@ -479,9 +496,11 @@ impl PubXvbApi {
|
|||
output.push_str(&buf);
|
||||
}
|
||||
let tick = std::mem::take(&mut gui_api.tick);
|
||||
let tick_distribute_hr = std::mem::take(&mut gui_api.tick_distribute_hr);
|
||||
*gui_api = Self {
|
||||
output,
|
||||
tick,
|
||||
tick_distribute_hr,
|
||||
..pub_api.clone()
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue