Skip to content

Commit 573fd56

Browse files
committed
log cleanup
1 parent dda287c commit 573fd56

File tree

4 files changed

+31
-14
lines changed

4 files changed

+31
-14
lines changed

src/args.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clap::{arg, Parser};
44
pub struct BalanceArgs {
55
#[arg(
66
value_name = "ADDRESS",
7-
help = "The account address to fetch the balance of"
7+
help = "The account address to fetch the balance of."
88
)]
99
pub address: Option<String>,
1010
}
@@ -56,7 +56,7 @@ pub struct MineArgs {
5656
long,
5757
short,
5858
value_name = "CORES_COUNT",
59-
help = "The number of CPU cores to allocate to mining",
59+
help = "The number of CPU cores to allocate to mining.",
6060
default_value = "1"
6161
)]
6262
pub cores: u64,
@@ -65,15 +65,15 @@ pub struct MineArgs {
6565
long,
6666
short,
6767
value_name = "SECONDS",
68-
help = "The number seconds before the deadline to stop mining and start submitting",
68+
help = "The number seconds before the deadline to stop mining and start submitting.",
6969
default_value = "5"
7070
)]
7171
pub buffer_time: u64,
7272
}
7373

7474
#[derive(Parser, Debug)]
7575
pub struct ProofArgs {
76-
#[arg(value_name = "ADDRESS", help = "The address of the proof to fetch")]
76+
#[arg(value_name = "ADDRESS", help = "The address of the proof to fetch.")]
7777
pub address: Option<String>,
7878
}
7979

@@ -102,8 +102,8 @@ pub struct TransferArgs {
102102
pub amount: f64,
103103

104104
#[arg(
105-
value_name = "WALLET_ADDRESS",
106-
help = "The wallet address of the receipient."
105+
value_name = "RECIPIENT_ADDRESS",
106+
help = "The account address of the receipient."
107107
)]
108108
pub to: String,
109109
}

src/mine.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl Miner {
4343
get_updated_proof_with_authority(&self.rpc_client, signer.pubkey(), last_hash_at)
4444
.await;
4545
println!(
46-
"\nStake: {} ORE\n{} Multiplier: {:12}x",
46+
"\n\nStake: {} ORE\n{} Multiplier: {:12}x",
4747
amount_u64_to_string(proof.balance),
4848
if last_hash_at.gt(&0) {
4949
format!(
@@ -151,7 +151,7 @@ impl Miner {
151151
if timer.elapsed().as_secs().ge(&cutoff_time) {
152152
if i.id == 0 {
153153
progress_bar.set_message(format!(
154-
"Mining... ({} difficulty)",
154+
"Mining... (difficulty {})",
155155
global_best_difficulty,
156156
));
157157
}
@@ -161,9 +161,12 @@ impl Miner {
161161
}
162162
} else if i.id == 0 {
163163
progress_bar.set_message(format!(
164-
"Mining... ({} difficulty, {} sec remaining)",
164+
"Mining... (difficulty {}, time {})",
165165
global_best_difficulty,
166-
cutoff_time.saturating_sub(timer.elapsed().as_secs()),
166+
format_duration(
167+
cutoff_time.saturating_sub(timer.elapsed().as_secs())
168+
as u32
169+
),
167170
));
168171
}
169172
}
@@ -195,7 +198,7 @@ impl Miner {
195198

196199
// Update log
197200
progress_bar.finish_with_message(format!(
198-
"Best hash: {} (difficulty: {})",
201+
"Best hash: {} (difficulty {})",
199202
bs58::encode(best_hash.h).into_string(),
200203
best_difficulty
201204
));
@@ -260,3 +263,9 @@ impl Miner {
260263
fn calculate_multiplier(balance: u64, top_balance: u64) -> f64 {
261264
1.0 + (balance as f64 / top_balance as f64).min(1.0f64)
262265
}
266+
267+
fn format_duration(seconds: u32) -> String {
268+
let minutes = seconds / 60;
269+
let remaining_seconds = seconds % 60;
270+
format!("{:02}:{:02}", minutes, remaining_seconds)
271+
}

src/send_and_confirm.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::time::Duration;
22

3+
use chrono::Local;
34
use colored::*;
45
use solana_client::{
56
client_error::{ClientError, ClientErrorKind, Result as ClientResult},
@@ -153,6 +154,13 @@ impl Miner {
153154
TransactionConfirmationStatus::Processed => {}
154155
TransactionConfirmationStatus::Confirmed
155156
| TransactionConfirmationStatus::Finalized => {
157+
let now = Local::now();
158+
let formatted_time =
159+
now.format("%Y-%m-%d %H:%M:%S").to_string();
160+
progress_bar.println(format!(
161+
" Timestamp: {}",
162+
formatted_time
163+
));
156164
progress_bar.finish_with_message(format!(
157165
"{} {}",
158166
"OK".bold().green(),

src/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ pub async fn get_proof(client: &RpcClient, address: Pubkey) -> Proof {
5252
let data = client
5353
.get_account_data(&address)
5454
.await
55-
.expect("Failed to get miner account");
56-
*Proof::try_from_bytes(&data).expect("Failed to parse miner account")
55+
.expect("Failed to get proof account");
56+
*Proof::try_from_bytes(&data).expect("Failed to parse proof account")
5757
}
5858

5959
pub async fn get_clock(client: &RpcClient) -> Clock {
6060
let data = client
6161
.get_account_data(&sysvar::clock::ID)
6262
.await
63-
.expect("Failed to get miner account");
63+
.expect("Failed to get clock account");
6464
bincode::deserialize::<Clock>(&data).expect("Failed to deserialize clock")
6565
}
6666

0 commit comments

Comments
 (0)