Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Define const fn StakeState::size_of for stake account size #24416

Merged
merged 1 commit into from
Apr 19, 2022
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: 1 addition & 1 deletion cli/src/cluster_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2113,7 +2113,7 @@ impl RentLengthValue {
pub fn length(&self) -> usize {
match self {
Self::Nonce => NonceState::size(),
Self::Stake => std::mem::size_of::<StakeState>(),
Self::Stake => StakeState::size_of(),
Self::System => 0,
Self::Vote => VoteState::size_of(),
Self::Bytes(l) => *l,
Expand Down
4 changes: 2 additions & 2 deletions cli/src/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ pub fn process_create_stake_account(
}

let minimum_balance =
rpc_client.get_minimum_balance_for_rent_exemption(std::mem::size_of::<StakeState>())?;
rpc_client.get_minimum_balance_for_rent_exemption(StakeState::size_of())?;

if lamports < minimum_balance {
return Err(CliError::BadParameter(format!(
Expand Down Expand Up @@ -1784,7 +1784,7 @@ pub fn process_split_stake(
}

let minimum_balance =
rpc_client.get_minimum_balance_for_rent_exemption(std::mem::size_of::<StakeState>())?;
rpc_client.get_minimum_balance_for_rent_exemption(StakeState::size_of())?;

if lamports < minimum_balance {
return Err(CliError::BadParameter(format!(
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ fn test_stake_split() {

// Create stake account, identity is authority
let minimum_stake_balance = rpc_client
.get_minimum_balance_for_rent_exemption(std::mem::size_of::<StakeState>())
.get_minimum_balance_for_rent_exemption(StakeState::size_of())
.unwrap();
let stake_keypair = keypair_from_seed(&[0u8; 32]).unwrap();
let stake_account_pubkey = stake_keypair.pubkey();
Expand Down Expand Up @@ -1227,7 +1227,7 @@ fn test_stake_set_lockup() {

// Create stake account, identity is authority
let minimum_stake_balance = rpc_client
.get_minimum_balance_for_rent_exemption(std::mem::size_of::<StakeState>())
.get_minimum_balance_for_rent_exemption(StakeState::size_of())
.unwrap();

let stake_keypair = keypair_from_seed(&[0u8; 32]).unwrap();
Expand Down
Loading