Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mining_node): mining worker name for tari_mining_node #3185

Merged
merged 2 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions applications/tari_mining_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct MinerConfig {
pub validate_tip_timeout_sec: u64,
pub mining_pool_address: String,
pub mining_wallet_address: String,
pub mining_worker_name: String,
}

#[derive(Serialize, Deserialize, Debug)]
Expand All @@ -75,6 +76,7 @@ impl Default for MinerConfig {
validate_tip_timeout_sec: 30,
mining_pool_address: "".to_string(),
mining_wallet_address: "".to_string(),
mining_worker_name: "".to_string(),
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion applications/tari_mining_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,16 @@ async fn main_inner() -> Result<(), ExitCodes> {
config.mine_on_tip_only = global.mine_on_tip_only;
config.num_mining_threads = global.num_mining_threads;
config.validate_tip_timeout_sec = global.validate_tip_timeout_sec;
config.mining_worker_name = global.mining_worker_name.clone();
debug!("{:?}", bootstrap);
debug!("{:?}", config);

if !config.mining_wallet_address.is_empty() && !config.mining_pool_address.is_empty() {
let url = config.mining_pool_address.clone();
let miner_address = config.mining_wallet_address.clone();
let mut miner_address = config.mining_wallet_address.clone();
if !config.mining_worker_name.is_empty() {
miner_address += &format!("{}{}", ".", &config.mining_worker_name);
}
let mut mc = Controller::new().unwrap_or_else(|e| {
panic!("Error loading mining controller: {}", e);
});
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_mining_node/src/stratum/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl Controller {
self.stream = None;
} else {
let status = format!("Connection Status: Connected to server at {}.", self.server_url);
warn!("{}", status);
info!("{}", status);
}
next_server_retry = time::get_time().sec + server_retry_interval;
if self.stream.is_none() {
Expand Down
1 change: 1 addition & 0 deletions common/config/presets/tari_config_example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -542,3 +542,4 @@ transcoder_host_address = "127.0.0.1:7879"
# Stratum Mode configuration
# mining_pool_address = "miningcore.tarilabs.com:3052"
# mining_wallet_address = "YOUR_WALLET_PUBLIC_KEY"
# mining_worker_name = "worker1"
9 changes: 9 additions & 0 deletions common/src/configuration/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ pub struct GlobalConfig {
pub validate_tip_timeout_sec: u64,
pub mining_pool_address: String,
pub mining_wallet_address: String,
pub mining_worker_name: String,
}

impl GlobalConfig {
Expand Down Expand Up @@ -683,6 +684,13 @@ fn convert_node_config(
let mining_pool_address = cfg.get_str(&key).unwrap_or_else(|_| "".to_string());
let key = "mining_node.mining_wallet_address";
let mining_wallet_address = cfg.get_str(&key).unwrap_or_else(|_| "".to_string());
let key = "mining_node.mining_worker_name";
let mining_worker_name = cfg
.get_str(&key)
.unwrap_or_else(|_| "".to_string())
.chars()
.filter(|c| c.is_alphanumeric())
.collect::<String>();

Ok(GlobalConfig {
autoupdate_check_interval,
Expand Down Expand Up @@ -769,6 +777,7 @@ fn convert_node_config(
validate_tip_timeout_sec,
mining_pool_address,
mining_wallet_address,
mining_worker_name,
})
}

Expand Down