Skip to content

Commit 0ac1be8

Browse files
committed
proof printout
1 parent d8404ef commit 0ac1be8

File tree

4 files changed

+79
-18
lines changed

4 files changed

+79
-18
lines changed

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/args.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,20 @@ pub struct CloseArgs {}
4848
#[derive(Parser, Debug)]
4949
pub struct ConfigArgs {}
5050

51-
#[cfg(feature = "admin")]
52-
#[derive(Parser, Debug)]
53-
pub struct PauseArgs {}
54-
5551
#[cfg(feature = "admin")]
5652
#[derive(Parser, Debug)]
5753
pub struct InitializeArgs {}
5854

5955
#[derive(Parser, Debug)]
6056
pub struct MineArgs {
61-
// #[cfg(not(feature = "gpu"))]
6257
#[arg(
6358
long,
6459
short,
65-
value_name = "THREAD_COUNT",
66-
help = "The number of CPU threads to allocate to mining",
60+
value_name = "CORES_COUNT",
61+
help = "The number of CPU cores to allocate to mining",
6762
default_value = "1"
6863
)]
69-
pub threads: u64,
64+
pub cores: u64,
7065

7166
#[arg(
7267
long,
@@ -78,6 +73,16 @@ pub struct MineArgs {
7873
pub buffer_time: u64,
7974
}
8075

76+
#[derive(Parser, Debug)]
77+
pub struct ProofArgs {
78+
#[arg(
79+
index = 0,
80+
value_name = "ADDRESS",
81+
help = "The address of the proof to fetch"
82+
)]
83+
pub address: Option<String>,
84+
}
85+
8186
#[derive(Parser, Debug)]
8287
pub struct RewardsArgs {}
8388

@@ -98,12 +103,6 @@ pub struct StakeArgs {
98103
pub sender: Option<String>,
99104
}
100105

101-
#[cfg(feature = "admin")]
102-
#[derive(Parser, Debug)]
103-
pub struct UpdateAdminArgs {
104-
pub new_admin: String,
105-
}
106-
107106
#[derive(Parser, Debug)]
108107
pub struct UpgradeArgs {
109108
#[arg(

src/main.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ mod claim;
66
mod close;
77
mod config;
88
mod cu_limits;
9+
mod dynamic_fee;
910
#[cfg(feature = "admin")]
1011
mod initialize;
1112
mod mine;
1213
mod open;
14+
mod proof;
1315
mod rewards;
1416
mod send_and_confirm;
1517
mod stake;
1618
mod upgrade;
1719
mod utils;
18-
mod dynamic_fee;
1920

2021
use std::sync::Arc;
2122

@@ -60,6 +61,9 @@ enum Commands {
6061
#[command(about = "Start mining")]
6162
Mine(MineArgs),
6263

64+
#[command(about = "Proof")]
65+
Proof(ProofArgs),
66+
6367
#[command(about = "Fetch the current reward rate for each difficulty level")]
6468
Rewards(RewardsArgs),
6569

@@ -143,7 +147,6 @@ struct Args {
143147
global = true
144148
)]
145149
dynamic_fee_max: Option<u64>,
146-
147150

148151
#[command(subcommand)]
149152
command: Commands,
@@ -168,7 +171,9 @@ async fn main() {
168171
// Initialize miner.
169172
let cluster = args.rpc.unwrap_or(cli_config.json_rpc_url);
170173
let default_keypair = args.keypair.unwrap_or(cli_config.keypair_path.clone());
171-
let fee_payer_filepath = args.fee_payer_filepath.unwrap_or(cli_config.keypair_path.clone());
174+
let fee_payer_filepath = args
175+
.fee_payer_filepath
176+
.unwrap_or(cli_config.keypair_path.clone());
172177
let rpc_client = RpcClient::new_with_commitment(cluster, CommitmentConfig::confirmed());
173178

174179
let miner = Arc::new(Miner::new(
@@ -204,6 +209,9 @@ async fn main() {
204209
Commands::Mine(args) => {
205210
miner.mine(args).await;
206211
}
212+
Commands::Proof(args) => {
213+
miner.proof(args).await;
214+
}
207215
Commands::Rewards(_) => {
208216
miner.rewards().await;
209217
}
@@ -237,7 +245,7 @@ impl Miner {
237245
dynamic_fee_url,
238246
dynamic_fee_strategy,
239247
dynamic_fee_max,
240-
fee_payer_filepath
248+
fee_payer_filepath,
241249
}
242250
}
243251

src/proof.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
use std::str::FromStr;
2+
3+
use ore_api::consts::TOKEN_DECIMALS;
4+
use solana_program::pubkey::Pubkey;
5+
use solana_sdk::signature::Signer;
6+
use spl_token::amount_to_ui_amount;
7+
8+
use crate::{
9+
args::ProofArgs,
10+
utils::{get_proof, proof_pubkey},
11+
Miner,
12+
};
13+
14+
impl Miner {
15+
pub async fn proof(&self, args: ProofArgs) {
16+
let signer = self.signer();
17+
let address = if let Some(address) = args.address {
18+
Pubkey::from_str(&address).unwrap()
19+
} else {
20+
proof_pubkey(signer.pubkey())
21+
};
22+
let proof = get_proof(&self.rpc_client, address).await;
23+
println!("Address: {:?}", address);
24+
println!("Authority: {:?}", proof.authority);
25+
println!(
26+
"Balance: {:?} ORE",
27+
amount_to_ui_amount(proof.balance, TOKEN_DECIMALS)
28+
);
29+
println!(
30+
"Last hash: {}",
31+
solana_sdk::hash::Hash::new_from_array(proof.last_hash).to_string()
32+
);
33+
println!("Last hash at: {:?}", proof.last_hash_at);
34+
println!("Last stake at: {:?}", proof.last_stake_at);
35+
println!("Miner: {:?}", proof.miner);
36+
println!("Total hashes: {:?}", proof.total_hashes);
37+
println!(
38+
"Total rewards: {:?} ORE",
39+
amount_to_ui_amount(proof.total_rewards, TOKEN_DECIMALS)
40+
);
41+
}
42+
}

0 commit comments

Comments
 (0)