Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit eb6cd99

Browse files
mvinesmergify[bot]
authored andcommitted
More variable renaming
1 parent 48ab307 commit eb6cd99

File tree

1 file changed

+46
-34
lines changed

1 file changed

+46
-34
lines changed

stake-pool/cli/src/main.rs

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ fn command_create_pool(
106106
pool_fee_account.pubkey()
107107
);
108108

109-
let pool_account = Keypair::new();
110-
println!("Creating stake pool {}", pool_account.pubkey());
109+
let stake_pool_keypair = Keypair::new();
110+
println!("Creating stake pool {}", stake_pool_keypair.pubkey());
111111

112112
let validator_list = Keypair::new();
113113

@@ -117,7 +117,7 @@ fn command_create_pool(
117117
let pool_fee_account_balance = config
118118
.rpc_client
119119
.get_minimum_balance_for_rent_exemption(spl_token::state::Account::LEN)?;
120-
let pool_account_balance = config
120+
let stake_pool_account_lamports = config
121121
.rpc_client
122122
.get_minimum_balance_for_rent_exemption(get_packed_len::<StakePool>())?;
123123
let empty_validator_list = ValidatorList::new(max_validators);
@@ -127,14 +127,16 @@ fn command_create_pool(
127127
.get_minimum_balance_for_rent_exemption(validator_list_size)?;
128128
let total_rent_free_balances = mint_account_balance
129129
+ pool_fee_account_balance
130-
+ pool_account_balance
130+
+ stake_pool_account_lamports
131131
+ validator_list_balance;
132132

133133
let default_decimals = spl_token::native_mint::DECIMALS;
134134

135135
// Calculate withdraw authority used for minting pool tokens
136-
let (withdraw_authority, _) =
137-
find_withdraw_authority_program_address(&spl_stake_pool::id(), &pool_account.pubkey());
136+
let (withdraw_authority, _) = find_withdraw_authority_program_address(
137+
&spl_stake_pool::id(),
138+
&stake_pool_keypair.pubkey(),
139+
);
138140

139141
if config.verbose {
140142
println!("Stake pool withdraw authority {}", withdraw_authority);
@@ -161,8 +163,8 @@ fn command_create_pool(
161163
// Account for the stake pool
162164
system_instruction::create_account(
163165
&config.fee_payer.pubkey(),
164-
&pool_account.pubkey(),
165-
pool_account_balance,
166+
&stake_pool_keypair.pubkey(),
167+
stake_pool_account_lamports,
166168
get_packed_len::<StakePool>() as u64,
167169
&spl_stake_pool::id(),
168170
),
@@ -192,7 +194,7 @@ fn command_create_pool(
192194
// Initialize stake pool account
193195
spl_stake_pool::instruction::initialize(
194196
&spl_stake_pool::id(),
195-
&pool_account.pubkey(),
197+
&stake_pool_keypair.pubkey(),
196198
&config.owner.pubkey(),
197199
&validator_list.pubkey(),
198200
&mint_account.pubkey(),
@@ -212,7 +214,7 @@ fn command_create_pool(
212214
)?;
213215
let mut signers = vec![
214216
config.fee_payer.as_ref(),
215-
&pool_account,
217+
&stake_pool_keypair,
216218
&validator_list,
217219
&mint_account,
218220
&pool_fee_account,
@@ -599,17 +601,17 @@ fn command_list(config: &Config, stake_pool_address: &Pubkey) -> CommandResult {
599601
return Err("No accounts found.".to_string().into());
600602
}
601603

602-
let mut total_balance: u64 = 0;
604+
let mut total_lamports: u64 = 0;
603605
for (pubkey, lamports, stake_state) in accounts {
604-
total_balance += lamports;
606+
total_lamports += lamports;
605607
println!(
606608
"Stake Account: {}\tVote Account: {}\t{}",
607609
pubkey,
608610
stake_state.delegation().expect("delegation").voter_pubkey,
609611
Sol(lamports)
610612
);
611613
}
612-
println!("Total: {}", Sol(total_balance));
614+
println!("Total Stake: {}", Sol(total_lamports));
613615

614616
Ok(())
615617
}
@@ -638,11 +640,11 @@ fn command_update(config: &Config, stake_pool_address: &Pubkey) -> CommandResult
638640

639641
let mut instructions: Vec<Instruction> = vec![];
640642

641-
for chunk in accounts_to_update.chunks(MAX_ACCOUNTS_TO_UPDATE) {
643+
for accounts_chunk in accounts_to_update.chunks(MAX_ACCOUNTS_TO_UPDATE) {
642644
instructions.push(spl_stake_pool::instruction::update_validator_list_balance(
643645
&spl_stake_pool::id(),
644646
&stake_pool.validator_list,
645-
&chunk,
647+
&accounts_chunk,
646648
)?);
647649
}
648650

@@ -912,6 +914,8 @@ fn command_set_owner(
912914
}
913915

914916
fn main() {
917+
solana_logger::setup_with_default("solana=info");
918+
915919
let matches = App::new(crate_name!())
916920
.about(crate_description!())
917921
.version(crate_version!())
@@ -1280,8 +1284,6 @@ fn main() {
12801284
}
12811285
};
12821286

1283-
solana_logger::setup_with_default("solana=info");
1284-
12851287
let _ = match matches.subcommand() {
12861288
("create-pool", Some(arg_matches)) => {
12871289
let numerator = value_t_or_exit!(arg_matches, "fee_numerator", u64);
@@ -1297,61 +1299,71 @@ fn main() {
12971299
)
12981300
}
12991301
("create-validator-stake", Some(arg_matches)) => {
1300-
let pool_account = pubkey_of(arg_matches, "pool").unwrap();
1301-
let vote_account = pubkey_of(arg_matches, "vote_account").unwrap();
1302-
command_vsa_create(&config, &pool_account, &vote_account)
1302+
let stake_pool_address = pubkey_of(arg_matches, "pool").unwrap();
1303+
let vote_account_address = pubkey_of(arg_matches, "vote_account_address").unwrap();
1304+
command_vsa_create(&config, &stake_pool_address, &vote_account_address)
13031305
}
13041306
("add-validator", Some(arg_matches)) => {
1305-
let pool_account = pubkey_of(arg_matches, "pool").unwrap();
1307+
let stake_pool_address = pubkey_of(arg_matches, "pool").unwrap();
13061308
let stake_account = pubkey_of(arg_matches, "stake_account").unwrap();
13071309
let token_receiver: Option<Pubkey> = pubkey_of(arg_matches, "token_receiver");
1308-
command_vsa_add(&config, &pool_account, &stake_account, &token_receiver)
1310+
command_vsa_add(
1311+
&config,
1312+
&stake_pool_address,
1313+
&stake_account,
1314+
&token_receiver,
1315+
)
13091316
}
13101317
("remove-validator", Some(arg_matches)) => {
1311-
let pool_account = pubkey_of(arg_matches, "pool").unwrap();
1318+
let stake_pool_address = pubkey_of(arg_matches, "pool").unwrap();
13121319
let stake_account = pubkey_of(arg_matches, "stake_account").unwrap();
13131320
let withdraw_from = pubkey_of(arg_matches, "withdraw_from").unwrap();
13141321
let new_authority: Option<Pubkey> = pubkey_of(arg_matches, "new_authority");
13151322
command_vsa_remove(
13161323
&config,
1317-
&pool_account,
1324+
&stake_pool_address,
13181325
&stake_account,
13191326
&withdraw_from,
13201327
&new_authority,
13211328
)
13221329
}
13231330
("deposit", Some(arg_matches)) => {
1324-
let pool_account = pubkey_of(arg_matches, "pool").unwrap();
1331+
let stake_pool_address = pubkey_of(arg_matches, "pool").unwrap();
13251332
let stake_account = pubkey_of(arg_matches, "stake_account").unwrap();
13261333
let token_receiver: Option<Pubkey> = pubkey_of(arg_matches, "token_receiver");
1327-
command_deposit(&config, &pool_account, &stake_account, &token_receiver)
1334+
command_deposit(
1335+
&config,
1336+
&stake_pool_address,
1337+
&stake_account,
1338+
&token_receiver,
1339+
)
13281340
}
13291341
("list", Some(arg_matches)) => {
1330-
let pool_account = pubkey_of(arg_matches, "pool").unwrap();
1331-
command_list(&config, &pool_account)
1342+
let stake_pool_address = pubkey_of(arg_matches, "pool").unwrap();
1343+
command_list(&config, &stake_pool_address)
13321344
}
13331345
("update", Some(arg_matches)) => {
1334-
let pool_account = pubkey_of(arg_matches, "pool").unwrap();
1335-
command_update(&config, &pool_account)
1346+
let stake_pool_address = pubkey_of(arg_matches, "pool").unwrap();
1347+
command_update(&config, &stake_pool_address)
13361348
}
13371349
("withdraw", Some(arg_matches)) => {
1338-
let pool_account = pubkey_of(arg_matches, "pool").unwrap();
1350+
let stake_pool_address = pubkey_of(arg_matches, "pool").unwrap();
13391351
let withdraw_from = pubkey_of(arg_matches, "withdraw_from").unwrap();
13401352
let pool_amount = value_t_or_exit!(arg_matches, "amount", f64);
13411353
let stake_receiver: Option<Pubkey> = pubkey_of(arg_matches, "stake_receiver");
13421354
command_withdraw(
13431355
&config,
1344-
&pool_account,
1356+
&stake_pool_address,
13451357
pool_amount,
13461358
&withdraw_from,
13471359
&stake_receiver,
13481360
)
13491361
}
13501362
("set-owner", Some(arg_matches)) => {
1351-
let pool_account = pubkey_of(arg_matches, "pool").unwrap();
1363+
let stake_pool_address = pubkey_of(arg_matches, "pool").unwrap();
13521364
let new_owner: Option<Pubkey> = pubkey_of(arg_matches, "new_owner");
13531365
let new_fee_receiver: Option<Pubkey> = pubkey_of(arg_matches, "new_fee_receiver");
1354-
command_set_owner(&config, &pool_account, &new_owner, &new_fee_receiver)
1366+
command_set_owner(&config, &stake_pool_address, &new_owner, &new_fee_receiver)
13551367
}
13561368
_ => unreachable!(),
13571369
}

0 commit comments

Comments
 (0)