Remove word pair from address generator seed string (#7802)
* Remove word pair from address generator seed string
This commit is contained in:
parent
4f663a2a86
commit
5947ef7706
|
@ -3,28 +3,21 @@ use solana_sdk::{pubkey::Pubkey, system_instruction::create_address_with_seed};
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct AddressGenerator {
|
pub struct AddressGenerator {
|
||||||
base_pubkey: Pubkey,
|
base_pubkey: Pubkey,
|
||||||
base_seed: String,
|
|
||||||
program_id: Pubkey,
|
program_id: Pubkey,
|
||||||
nth: usize,
|
nth: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddressGenerator {
|
impl AddressGenerator {
|
||||||
pub fn new(base_pubkey: &Pubkey, base_seed: &str, program_id: &Pubkey) -> Self {
|
pub fn new(base_pubkey: &Pubkey, program_id: &Pubkey) -> Self {
|
||||||
Self {
|
Self {
|
||||||
base_pubkey: *base_pubkey,
|
base_pubkey: *base_pubkey,
|
||||||
base_seed: base_seed.to_string(),
|
|
||||||
program_id: *program_id,
|
program_id: *program_id,
|
||||||
nth: 0,
|
nth: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn nth(&self, nth: usize) -> Pubkey {
|
pub fn nth(&self, nth: usize) -> Pubkey {
|
||||||
create_address_with_seed(
|
create_address_with_seed(&self.base_pubkey, &format!("{}", nth), &self.program_id).unwrap()
|
||||||
&self.base_pubkey,
|
|
||||||
&format!("{}:{}", self.base_seed, nth),
|
|
||||||
&self.program_id,
|
|
||||||
)
|
|
||||||
.unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::should_implement_trait)]
|
#[allow(clippy::should_implement_trait)]
|
||||||
|
|
|
@ -89,11 +89,8 @@ pub fn create_and_add_stakes(
|
||||||
genesis_config.ticks_per_slot,
|
genesis_config.ticks_per_slot,
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut address_generator = AddressGenerator::new(
|
let mut address_generator =
|
||||||
&authorized.staker,
|
AddressGenerator::new(&authorized.staker, &solana_stake_program::id());
|
||||||
staker_info.name,
|
|
||||||
&solana_stake_program::id(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let stake_rent_reserve = StakeState::get_rent_exempt_reserve(&genesis_config.rent);
|
let stake_rent_reserve = StakeState::get_rent_exempt_reserve(&genesis_config.rent);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue