_id => _pubkey variable renaming (#4419)

* wallet: rename *_account_id to *_account_pubkey

* s/from_id/from_pubkey/g

* s/node_id/node_pubkey/g

* s/stake_id/stake_pubkey/g

* s/voter_id/voter_pubkey/g

* s/vote_id/vote_pubkey/g

* s/delegate_id/delegate_pubkey/g

* s/account_id/account_pubkey/g

* s/to_id/to_pubkey/g

* s/my_id/my_pubkey/g

* cargo fmt

* s/staker_id/staker_pubkey/g

* s/mining_pool_id/mining_pool_pubkey/g

* s/leader_id/leader_pubkey/g

* cargo fmt

* s/funding_id/funding_pubkey/g
This commit is contained in:
Michael Vines
2019-05-23 23:20:04 -07:00
committed by GitHub
parent 94beb4b8c2
commit cfe5afd34c
42 changed files with 697 additions and 620 deletions

View File

@ -15,7 +15,7 @@ use std::path::Path;
#[derive(Serialize, Deserialize, Debug)]
pub struct GenesisBlock {
pub accounts: Vec<(Pubkey, Account)>,
pub bootstrap_leader_id: Pubkey,
pub bootstrap_leader_pubkey: Pubkey,
pub epoch_warmup: bool,
pub fee_calculator: FeeCalculator,
pub native_instruction_processors: Vec<(String, Pubkey)>,
@ -43,13 +43,13 @@ pub fn create_genesis_block(lamports: u64) -> (GenesisBlock, Keypair) {
impl GenesisBlock {
pub fn new(
bootstrap_leader_id: &Pubkey,
bootstrap_leader_pubkey: &Pubkey,
accounts: &[(Pubkey, Account)],
native_instruction_processors: &[(String, Pubkey)],
) -> Self {
Self {
accounts: accounts.to_vec(),
bootstrap_leader_id: *bootstrap_leader_id, // TODO: leader_schedule to derive from actual stakes, instead ;)
bootstrap_leader_pubkey: *bootstrap_leader_pubkey, // TODO: leader_schedule to derive from actual stakes, instead ;)
epoch_warmup: true,
fee_calculator: FeeCalculator::default(),
native_instruction_processors: native_instruction_processors.to_vec(),

View File

@ -20,8 +20,13 @@ pub enum LoaderInstruction {
Finalize,
}
pub fn write(account_id: &Pubkey, program_id: &Pubkey, offset: u32, bytes: Vec<u8>) -> Instruction {
let account_metas = vec![AccountMeta::new(*account_id, true)];
pub fn write(
account_pubkey: &Pubkey,
program_id: &Pubkey,
offset: u32,
bytes: Vec<u8>,
) -> Instruction {
let account_metas = vec![AccountMeta::new(*account_pubkey, true)];
Instruction::new(
*program_id,
&LoaderInstruction::Write { offset, bytes },
@ -29,7 +34,7 @@ pub fn write(account_id: &Pubkey, program_id: &Pubkey, offset: u32, bytes: Vec<u
)
}
pub fn finalize(account_id: &Pubkey, program_id: &Pubkey) -> Instruction {
let account_metas = vec![AccountMeta::new(*account_id, true)];
pub fn finalize(account_pubkey: &Pubkey, program_id: &Pubkey) -> Instruction {
let account_metas = vec![AccountMeta::new(*account_pubkey, true)];
Instruction::new(*program_id, &LoaderInstruction::Finalize, account_metas)
}

View File

@ -47,15 +47,15 @@ pub enum SystemInstruction {
}
pub fn create_account(
from_id: &Pubkey,
to_id: &Pubkey,
from_pubkey: &Pubkey,
to_pubkey: &Pubkey,
lamports: u64,
space: u64,
program_id: &Pubkey,
) -> Instruction {
let account_metas = vec![
AccountMeta::new(*from_id, true),
AccountMeta::new(*to_id, false),
AccountMeta::new(*from_pubkey, true),
AccountMeta::new(*to_pubkey, false),
];
Instruction::new(
system_program::id(),
@ -69,13 +69,13 @@ pub fn create_account(
}
/// Create and sign a transaction to create a system account
pub fn create_user_account(from_id: &Pubkey, to_id: &Pubkey, lamports: u64) -> Instruction {
pub fn create_user_account(from_pubkey: &Pubkey, to_pubkey: &Pubkey, lamports: u64) -> Instruction {
let program_id = system_program::id();
create_account(from_id, to_id, lamports, 0, &program_id)
create_account(from_pubkey, to_pubkey, lamports, 0, &program_id)
}
pub fn assign(from_id: &Pubkey, program_id: &Pubkey) -> Instruction {
let account_metas = vec![AccountMeta::new(*from_id, true)];
pub fn assign(from_pubkey: &Pubkey, program_id: &Pubkey) -> Instruction {
let account_metas = vec![AccountMeta::new(*from_pubkey, true)];
Instruction::new(
system_program::id(),
&SystemInstruction::Assign {
@ -85,10 +85,10 @@ pub fn assign(from_id: &Pubkey, program_id: &Pubkey) -> Instruction {
)
}
pub fn transfer(from_id: &Pubkey, to_id: &Pubkey, lamports: u64) -> Instruction {
pub fn transfer(from_pubkey: &Pubkey, to_pubkey: &Pubkey, lamports: u64) -> Instruction {
let account_metas = vec![
AccountMeta::new(*from_id, true),
AccountMeta::new(*to_id, false),
AccountMeta::new(*from_pubkey, true),
AccountMeta::new(*to_pubkey, false),
];
Instruction::new(
system_program::id(),
@ -98,10 +98,10 @@ pub fn transfer(from_id: &Pubkey, to_id: &Pubkey, lamports: u64) -> Instruction
}
/// Create and sign new SystemInstruction::Transfer transaction to many destinations
pub fn transfer_many(from_id: &Pubkey, to_lamports: &[(Pubkey, u64)]) -> Vec<Instruction> {
pub fn transfer_many(from_pubkey: &Pubkey, to_lamports: &[(Pubkey, u64)]) -> Vec<Instruction> {
to_lamports
.iter()
.map(|(to_id, lamports)| transfer(from_id, to_id, *lamports))
.map(|(to_pubkey, lamports)| transfer(from_pubkey, to_pubkey, *lamports))
.collect()
}