Skip to content

Commit

Permalink
feat(miner): friendlier miner output
Browse files Browse the repository at this point in the history
  • Loading branch information
sdbondi committed Jun 22, 2022
1 parent 3965267 commit dea8601
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion applications/tari_miner/log4rs_sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ appenders:
pattern: "{d(%H:%M)} {h({l}):5} {m}{n}"
filters:
- kind: threshold
level: info
level: warn
# An appender named "base_layer" that writes to a file with a custom pattern encoder
miner:
kind: rolling_file
Expand Down
18 changes: 14 additions & 4 deletions applications/tari_miner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ async fn main_inner() -> Result<(), ExitError> {
sleep(config.wait_timeout()).await;
},
Ok(submitted) => {
println!("💰 Found block");
info!(target: LOG_TARGET, "Found block");
if submitted {
blocks_found += 1;
Expand All @@ -196,12 +197,12 @@ async fn main_inner() -> Result<(), ExitError> {

async fn connect(config: &MinerConfig) -> Result<(BaseNodeClient<Channel>, WalletClient<Channel>), MinerError> {
let base_node_addr = multiaddr_to_socketaddr(&config.base_node_addr)?;
println!("Connecting to base node at {}", base_node_addr);
error!(target: LOG_TARGET, "Connecting to base node at {}", base_node_addr);
println!("🔗 Connecting to base node at {}", config.base_node_addr);
info!(target: LOG_TARGET, "Connecting to base node at {}", base_node_addr);
let node_conn = BaseNodeClient::connect(format!("http://{}", base_node_addr)).await?;
let wallet_addr = multiaddr_to_socketaddr(&config.wallet_addr)?;
println!("Connecting to wallet at {}", config.wallet_addr);
error!(target: LOG_TARGET, "Connecting to wallet at {}", wallet_addr);
println!("👛 Connecting to wallet at {}", config.wallet_addr);
info!(target: LOG_TARGET, "Connecting to wallet at {}", wallet_addr);
let wallet_conn = WalletClient::connect(format!("http://{}", wallet_addr)).await?;

Ok((node_conn, wallet_conn))
Expand Down Expand Up @@ -314,6 +315,15 @@ async fn mining_cycle(

async fn display_report(report: &MiningReport, num_mining_threads: usize) {
let hashrate = report.hashes as f64 / report.elapsed.as_micros() as f64;
println!(
"⛏ Miner {} reported {:.2}MH/s with total {:.2}MH/s over {} threads. Height: {}. Target: {})",
report.miner,
hashrate,
hashrate * num_mining_threads as f64,
num_mining_threads,
report.height,
report.target_difficulty,
);
info!(
target: LOG_TARGET,
"Miner {} reported {:.2}MH/s with total {:.2}MH/s over {} threads. Height: {}. Target: {})",
Expand Down

0 comments on commit dea8601

Please sign in to comment.