mirror of
https://github.com/hinto-janai/gupax.git
synced 2024-11-18 02:07:40 +00:00
helper: p2pool - add static [UserP2poolData]
This commit is contained in:
parent
b4a6dbec19
commit
016aeab1b6
1 changed files with 57 additions and 6 deletions
|
@ -243,6 +243,7 @@ impl Helper {
|
||||||
let path = path.clone();
|
let path = path.clone();
|
||||||
let mut api_path = path.clone();
|
let mut api_path = path.clone();
|
||||||
api_path.pop();
|
api_path.pop();
|
||||||
|
let pub_api = Arc::clone(&helper.lock().unwrap().pub_api_p2pool);
|
||||||
|
|
||||||
// [Simple]
|
// [Simple]
|
||||||
if state.simple {
|
if state.simple {
|
||||||
|
@ -256,6 +257,17 @@ impl Helper {
|
||||||
args.push("--local-api".to_string()); // Enable API
|
args.push("--local-api".to_string()); // Enable API
|
||||||
args.push("--no-color".to_string()); // Remove color escape sequences, Gupax terminal can't parse it :(
|
args.push("--no-color".to_string()); // Remove color escape sequences, Gupax terminal can't parse it :(
|
||||||
args.push("--mini".to_string()); // P2Pool Mini
|
args.push("--mini".to_string()); // P2Pool Mini
|
||||||
|
// Set static user data
|
||||||
|
pub_api.lock().unwrap().user = UserP2poolData {
|
||||||
|
mini: true,
|
||||||
|
address: state.address.clone(),
|
||||||
|
host: ip.to_string(),
|
||||||
|
rpc: rpc.to_string(),
|
||||||
|
zmq: zmq.to_string(),
|
||||||
|
log_level: "3".to_string(),
|
||||||
|
out_peers: "10".to_string(),
|
||||||
|
in_peers: "10".to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
// [Advanced]
|
// [Advanced]
|
||||||
} else {
|
} else {
|
||||||
|
@ -277,15 +289,25 @@ impl Helper {
|
||||||
args.push("--local-api".to_string()); // Enable API
|
args.push("--local-api".to_string()); // Enable API
|
||||||
args.push("--no-color".to_string()); // Remove color escape sequences
|
args.push("--no-color".to_string()); // Remove color escape sequences
|
||||||
if state.mini { args.push("--mini".to_string()); }; // Mini
|
if state.mini { args.push("--mini".to_string()); }; // Mini
|
||||||
|
// Set static user data
|
||||||
|
pub_api.lock().unwrap().user = UserP2poolData {
|
||||||
|
mini: state.mini,
|
||||||
|
address: state.address.clone(),
|
||||||
|
host: state.selected_ip.to_string(),
|
||||||
|
rpc: state.selected_rpc.to_string(),
|
||||||
|
zmq: state.selected_zmq.to_string(),
|
||||||
|
log_level: state.log_level.to_string(),
|
||||||
|
out_peers: state.out_peers.to_string(),
|
||||||
|
in_peers: state.in_peers.to_string(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print arguments to console
|
// Print arguments & user settings to console
|
||||||
crate::disk::print_dash(&format!("P2Pool | Launch arguments ... {:#?}", args));
|
crate::disk::print_dash(&format!("P2Pool | Launch arguments ... {:#?}", args));
|
||||||
|
|
||||||
// Spawn watchdog thread
|
// Spawn watchdog thread
|
||||||
let process = Arc::clone(&helper.lock().unwrap().p2pool);
|
let process = Arc::clone(&helper.lock().unwrap().p2pool);
|
||||||
let pub_api = Arc::clone(&helper.lock().unwrap().pub_api_p2pool);
|
|
||||||
let priv_api = Arc::clone(&helper.lock().unwrap().priv_api_p2pool);
|
let priv_api = Arc::clone(&helper.lock().unwrap().priv_api_p2pool);
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
Self::spawn_p2pool_watchdog(process, pub_api, priv_api, args, path);
|
Self::spawn_p2pool_watchdog(process, pub_api, priv_api, args, path);
|
||||||
|
@ -413,7 +435,7 @@ impl Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. If loop broke, we must be done here.
|
// 5. If loop broke, we must be done here.
|
||||||
info!("P2Pool | Advanced watchdog thread exiting... Goodbye!");
|
info!("P2Pool | Watchdog thread exiting... Goodbye!");
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- XMRig specific
|
//---------------------------------------------------------------------------------------------------- XMRig specific
|
||||||
|
@ -703,11 +725,40 @@ impl P2poolRegex {
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Public P2Pool API
|
//---------------------------------------------------------------------------------------------------- Public P2Pool API
|
||||||
|
// Static Public data that is only initialized once per P2Pool start.
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct UserP2poolData {
|
||||||
|
// Static user data that gets initialized once.
|
||||||
|
pub mini: bool, // Did the user start on the mini-chain?
|
||||||
|
pub address: String, // What address is the current p2pool paying out to? (This gets shortened to [4xxxxx...xxxxxx])
|
||||||
|
pub host: String, // What monerod are we using?
|
||||||
|
pub rpc: String, // What is the RPC port?
|
||||||
|
pub zmq: String, // What is the ZMQ port?
|
||||||
|
pub out_peers: String, // How many out-peers?
|
||||||
|
pub in_peers: String, // How many in-peers?
|
||||||
|
pub log_level: String, // What log level?
|
||||||
|
}
|
||||||
|
|
||||||
|
impl UserP2poolData {
|
||||||
|
fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
mini: true,
|
||||||
|
address: String::new(),
|
||||||
|
host: String::new(),
|
||||||
|
rpc: String::new(),
|
||||||
|
zmq: String::new(),
|
||||||
|
out_peers: String::new(),
|
||||||
|
in_peers: String::new(),
|
||||||
|
log_level: String::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// GUI thread interfaces with this.
|
// GUI thread interfaces with this.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct PubP2poolApi {
|
pub struct PubP2poolApi {
|
||||||
// One off
|
// Static data
|
||||||
pub mini: bool,
|
pub user: UserP2poolData,
|
||||||
// Output
|
// Output
|
||||||
pub output: String,
|
pub output: String,
|
||||||
// Uptime
|
// Uptime
|
||||||
|
@ -734,7 +785,7 @@ pub struct PubP2poolApi {
|
||||||
impl PubP2poolApi {
|
impl PubP2poolApi {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
mini: true,
|
user: UserP2poolData::new(),
|
||||||
output: String::with_capacity(56_000_000),
|
output: String::with_capacity(56_000_000),
|
||||||
uptime: HumanTime::new(),
|
uptime: HumanTime::new(),
|
||||||
payouts: 0,
|
payouts: 0,
|
||||||
|
|
Loading…
Reference in a new issue