More precise constructor names

This commit is contained in:
Greg Fitzgerald
2019-03-15 10:02:28 -06:00
parent 968022a1b0
commit e091aa87ea
13 changed files with 39 additions and 39 deletions

View File

@ -503,7 +503,7 @@ mod tests {
let instructions = vec![CompiledInstruction::new(0, &system_instruction, vec![0, 1])]; let instructions = vec![CompiledInstruction::new(0, &system_instruction, vec![0, 1])];
let tx = Transaction::new_with_instructions( let tx = Transaction::new_with_compiled_instructions(
&keypairs, &keypairs,
&[], &[],
blockhash, blockhash,

View File

@ -132,7 +132,7 @@ impl Drone {
space: 0, space: 0,
program_id: system_program::id(), program_id: system_program::id(),
}; };
let mut transaction = Transaction::new( let mut transaction = Transaction::new_signed(
&self.mint_keypair, &self.mint_keypair,
&[to], &[to],
&system_program::id(), &system_program::id(),
@ -408,7 +408,7 @@ mod tests {
space: 0, space: 0,
program_id: system_program::id(), program_id: system_program::id(),
}; };
let mut expected_tx = Transaction::new( let mut expected_tx = Transaction::new_signed(
&keypair, &keypair,
&[to], &[to],
&system_program::id(), &system_program::id(),

View File

@ -17,7 +17,7 @@ fn test_local_drone() {
space: 0, space: 0,
program_id: system_program::id(), program_id: system_program::id(),
}; };
let mut expected_tx = Transaction::new( let mut expected_tx = Transaction::new_signed(
&keypair, &keypair,
&[to], &[to],
&system_program::id(), &system_program::id(),

View File

@ -43,7 +43,7 @@ mod bpf {
// Call user program // Call user program
let program_id = load_program(&bank, &mint_keypair, &bpf_loader::id(), elf); let program_id = load_program(&bank, &mint_keypair, &bpf_loader::id(), elf);
let tx = Transaction::new( let tx = Transaction::new_signed(
&mint_keypair, &mint_keypair,
&[], &[],
&program_id, &program_id,
@ -86,7 +86,7 @@ mod bpf {
// Call user program // Call user program
let program_id = load_program(&bank, &mint_keypair, &loader_id, elf); let program_id = load_program(&bank, &mint_keypair, &loader_id, elf);
let tx = Transaction::new( let tx = Transaction::new_signed(
&mint_keypair, &mint_keypair,
&[], &[],
&program_id, &program_id,
@ -132,7 +132,7 @@ mod bpf {
// Call user program // Call user program
let program_id = load_program(&bank, &mint_keypair, &loader_id, elf); let program_id = load_program(&bank, &mint_keypair, &loader_id, elf);
let tx = Transaction::new( let tx = Transaction::new_signed(
&mint_keypair, &mint_keypair,
&[], &[],
&program_id, &program_id,

View File

@ -177,7 +177,7 @@ mod test {
let from = Keypair::new(); let from = Keypair::new();
let contract = Keypair::new(); let contract = Keypair::new();
let data = (1u8, 2u8, 3u8); let data = (1u8, 2u8, 3u8);
let tx = Transaction::new( let tx = Transaction::new_signed(
&from, &from,
&[contract.pubkey()], &[contract.pubkey()],
&id(), &id(),

View File

@ -14,7 +14,7 @@ fn test_program_native_failure() {
let program_id = load_program(&bank, &mint_keypair, &native_loader::id(), program); let program_id = load_program(&bank, &mint_keypair, &native_loader::id(), program);
// Call user program // Call user program
let tx = Transaction::new( let tx = Transaction::new_signed(
&mint_keypair, &mint_keypair,
&[], &[],
&program_id, &program_id,

View File

@ -15,7 +15,7 @@ fn test_program_native_noop() {
let program_id = load_program(&bank, &mint_keypair, &native_loader::id(), program); let program_id = load_program(&bank, &mint_keypair, &native_loader::id(), program);
// Call user program // Call user program
let tx = Transaction::new( let tx = Transaction::new_signed(
&mint_keypair, &mint_keypair,
&[], &[],
&program_id, &program_id,

View File

@ -90,7 +90,7 @@ impl StorageTransaction {
entry_height, entry_height,
signature, signature,
}; };
Transaction::new(from_keypair, &[], &id(), &program, recent_blockhash, 0) Transaction::new_signed(from_keypair, &[], &id(), &program, recent_blockhash, 0)
} }
pub fn new_advertise_recent_blockhash( pub fn new_advertise_recent_blockhash(
@ -103,7 +103,7 @@ impl StorageTransaction {
hash: storage_hash, hash: storage_hash,
entry_height, entry_height,
}; };
Transaction::new(from_keypair, &[], &id(), &program, recent_blockhash, 0) Transaction::new_signed(from_keypair, &[], &id(), &program, recent_blockhash, 0)
} }
pub fn new_proof_validation( pub fn new_proof_validation(
@ -116,7 +116,7 @@ impl StorageTransaction {
entry_height, entry_height,
proof_mask, proof_mask,
}; };
Transaction::new(from_keypair, &[], &id(), &program, recent_blockhash, 0) Transaction::new_signed(from_keypair, &[], &id(), &program, recent_blockhash, 0)
} }
pub fn new_reward_claim( pub fn new_reward_claim(
@ -125,6 +125,6 @@ impl StorageTransaction {
entry_height: u64, entry_height: u64,
) -> Transaction { ) -> Transaction {
let program = StorageProgram::ClaimStorageReward { entry_height }; let program = StorageProgram::ClaimStorageReward { entry_height };
Transaction::new(from_keypair, &[], &id(), &program, recent_blockhash, 0) Transaction::new_signed(from_keypair, &[], &id(), &program, recent_blockhash, 0)
} }
} }

View File

@ -1047,7 +1047,7 @@ mod tests {
let mut error_counters = ErrorCounters::default(); let mut error_counters = ErrorCounters::default();
let instructions = vec![CompiledInstruction::new(1, &(), vec![0])]; let instructions = vec![CompiledInstruction::new(1, &(), vec![0])];
let tx = Transaction::new_with_instructions::<Keypair>( let tx = Transaction::new_with_compiled_instructions::<Keypair>(
&[], &[],
&[], &[],
Hash::default(), Hash::default(),
@ -1071,7 +1071,7 @@ mod tests {
let keypair = Keypair::new(); let keypair = Keypair::new();
let instructions = vec![CompiledInstruction::new(1, &(), vec![0])]; let instructions = vec![CompiledInstruction::new(1, &(), vec![0])];
let tx = Transaction::new_with_instructions( let tx = Transaction::new_with_compiled_instructions(
&[&keypair], &[&keypair],
&[], &[],
Hash::default(), Hash::default(),
@ -1103,7 +1103,7 @@ mod tests {
accounts.push((key1, account)); accounts.push((key1, account));
let instructions = vec![CompiledInstruction::new(1, &(), vec![0])]; let instructions = vec![CompiledInstruction::new(1, &(), vec![0])];
let tx = Transaction::new_with_instructions( let tx = Transaction::new_with_compiled_instructions(
&[&keypair], &[&keypair],
&[], &[],
Hash::default(), Hash::default(),
@ -1131,7 +1131,7 @@ mod tests {
accounts.push((key0, account)); accounts.push((key0, account));
let instructions = vec![CompiledInstruction::new(1, &(), vec![0])]; let instructions = vec![CompiledInstruction::new(1, &(), vec![0])];
let tx = Transaction::new_with_instructions( let tx = Transaction::new_with_compiled_instructions(
&[&keypair], &[&keypair],
&[], &[],
Hash::default(), Hash::default(),
@ -1166,7 +1166,7 @@ mod tests {
accounts.push((key1, account)); accounts.push((key1, account));
let instructions = vec![CompiledInstruction::new(0, &(), vec![0, 1])]; let instructions = vec![CompiledInstruction::new(0, &(), vec![0, 1])];
let tx = Transaction::new_with_instructions( let tx = Transaction::new_with_compiled_instructions(
&[&keypair], &[&keypair],
&[key1], &[key1],
Hash::default(), Hash::default(),
@ -1238,7 +1238,7 @@ mod tests {
accounts.push((key6, account)); accounts.push((key6, account));
let instructions = vec![CompiledInstruction::new(0, &(), vec![0])]; let instructions = vec![CompiledInstruction::new(0, &(), vec![0])];
let tx = Transaction::new_with_instructions( let tx = Transaction::new_with_compiled_instructions(
&[&keypair], &[&keypair],
&[], &[],
Hash::default(), Hash::default(),
@ -1272,7 +1272,7 @@ mod tests {
accounts.push((key1, account)); accounts.push((key1, account));
let instructions = vec![CompiledInstruction::new(0, &(), vec![0])]; let instructions = vec![CompiledInstruction::new(0, &(), vec![0])];
let tx = Transaction::new_with_instructions( let tx = Transaction::new_with_compiled_instructions(
&[&keypair], &[&keypair],
&[], &[],
Hash::default(), Hash::default(),
@ -1305,7 +1305,7 @@ mod tests {
accounts.push((key1, account)); accounts.push((key1, account));
let instructions = vec![CompiledInstruction::new(0, &(), vec![0])]; let instructions = vec![CompiledInstruction::new(0, &(), vec![0])];
let tx = Transaction::new_with_instructions( let tx = Transaction::new_with_compiled_instructions(
&[&keypair], &[&keypair],
&[], &[],
Hash::default(), Hash::default(),
@ -1354,7 +1354,7 @@ mod tests {
CompiledInstruction::new(0, &(), vec![0]), CompiledInstruction::new(0, &(), vec![0]),
CompiledInstruction::new(1, &(), vec![0]), CompiledInstruction::new(1, &(), vec![0]),
]; ];
let tx = Transaction::new_with_instructions( let tx = Transaction::new_with_compiled_instructions(
&[&keypair], &[&keypair],
&[], &[],
Hash::default(), Hash::default(),
@ -1398,7 +1398,7 @@ mod tests {
let instructions = vec![CompiledInstruction::new(0, &(), vec![0, 1])]; let instructions = vec![CompiledInstruction::new(0, &(), vec![0, 1])];
// Simulate pay-to-self transaction, which loads the same account twice // Simulate pay-to-self transaction, which loads the same account twice
let tx = Transaction::new_with_instructions( let tx = Transaction::new_with_compiled_instructions(
&[&keypair], &[&keypair],
&[pubkey], &[pubkey],
Hash::default(), Hash::default(),

View File

@ -939,7 +939,7 @@ mod tests {
}, },
]; ];
let t1 = Transaction::new_with_instructions( let t1 = Transaction::new_with_compiled_instructions(
&[&mint_keypair], &[&mint_keypair],
&[key1, key2], &[key1, key2],
genesis_block.hash(), genesis_block.hash(),

View File

@ -18,7 +18,7 @@ impl LoaderTransaction {
fee: u64, fee: u64,
) -> Transaction { ) -> Transaction {
let instruction = LoaderInstruction::Write { offset, bytes }; let instruction = LoaderInstruction::Write { offset, bytes };
Transaction::new( Transaction::new_signed(
from_keypair, from_keypair,
&[], &[],
loader, loader,
@ -35,7 +35,7 @@ impl LoaderTransaction {
fee: u64, fee: u64,
) -> Transaction { ) -> Transaction {
let instruction = LoaderInstruction::Finalize; let instruction = LoaderInstruction::Finalize;
Transaction::new( Transaction::new_signed(
from_keypair, from_keypair,
&[], &[],
loader, loader,

View File

@ -25,7 +25,7 @@ impl SystemTransaction {
space, space,
program_id: *program_id, program_id: *program_id,
}; };
Transaction::new( Transaction::new_signed(
from_keypair, from_keypair,
&[*to], &[*to],
&system_program::id(), &system_program::id(),
@ -64,7 +64,7 @@ impl SystemTransaction {
let assign = SystemInstruction::Assign { let assign = SystemInstruction::Assign {
program_id: *program_id, program_id: *program_id,
}; };
Transaction::new( Transaction::new_signed(
from_keypair, from_keypair,
&[], &[],
&system_program::id(), &system_program::id(),
@ -82,7 +82,7 @@ impl SystemTransaction {
fee: u64, fee: u64,
) -> Transaction { ) -> Transaction {
let move_lamports = SystemInstruction::Move { lamports }; let move_lamports = SystemInstruction::Move { lamports };
Transaction::new( Transaction::new_signed(
from_keypair, from_keypair,
&[*to], &[*to],
&system_program::id(), &system_program::id(),
@ -108,7 +108,7 @@ impl SystemTransaction {
.collect(); .collect();
let to_keys: Vec<_> = moves.iter().map(|(to_key, _)| *to_key).collect(); let to_keys: Vec<_> = moves.iter().map(|(to_key, _)| *to_key).collect();
Transaction::new_with_instructions( Transaction::new_with_compiled_instructions(
&[from], &[from],
&to_keys, &to_keys,
recent_blockhash, recent_blockhash,

View File

@ -167,7 +167,7 @@ pub struct Transaction {
} }
impl Transaction { impl Transaction {
pub fn new<S: Serialize, T: KeypairUtil>( pub fn new_signed<S: Serialize, T: KeypairUtil>(
from_keypair: &T, from_keypair: &T,
transaction_keys: &[Pubkey], transaction_keys: &[Pubkey],
program_id: &Pubkey, program_id: &Pubkey,
@ -212,7 +212,7 @@ impl Transaction {
/// * `fee` - The transaction fee. /// * `fee` - The transaction fee.
/// * `program_ids` - The keys that identify programs used in the `instruction` vector. /// * `program_ids` - The keys that identify programs used in the `instruction` vector.
/// * `instructions` - Instructions that will be executed atomically. /// * `instructions` - Instructions that will be executed atomically.
pub fn new_with_instructions<T: KeypairUtil>( pub fn new_with_compiled_instructions<T: KeypairUtil>(
from_keypairs: &[&T], from_keypairs: &[&T],
keys: &[Pubkey], keys: &[Pubkey],
recent_blockhash: Hash, recent_blockhash: Hash,
@ -500,7 +500,7 @@ mod tests {
CompiledInstruction::new(0, &(), vec![0, 1]), CompiledInstruction::new(0, &(), vec![0, 1]),
CompiledInstruction::new(1, &(), vec![0, 2]), CompiledInstruction::new(1, &(), vec![0, 2]),
]; ];
let tx = Transaction::new_with_instructions( let tx = Transaction::new_with_compiled_instructions(
&[&key], &[&key],
&[key1, key2], &[key1, key2],
Hash::default(), Hash::default(),
@ -535,7 +535,7 @@ mod tests {
fn test_refs_invalid_program_id() { fn test_refs_invalid_program_id() {
let key = Keypair::new(); let key = Keypair::new();
let instructions = vec![CompiledInstruction::new(1, &(), vec![])]; let instructions = vec![CompiledInstruction::new(1, &(), vec![])];
let tx = Transaction::new_with_instructions( let tx = Transaction::new_with_compiled_instructions(
&[&key], &[&key],
&[], &[],
Hash::default(), Hash::default(),
@ -549,7 +549,7 @@ mod tests {
fn test_refs_invalid_account() { fn test_refs_invalid_account() {
let key = Keypair::new(); let key = Keypair::new();
let instructions = vec![CompiledInstruction::new(0, &(), vec![1])]; let instructions = vec![CompiledInstruction::new(0, &(), vec![1])];
let tx = Transaction::new_with_instructions( let tx = Transaction::new_with_compiled_instructions(
&[&key], &[&key],
&[], &[],
Hash::default(), Hash::default(),
@ -566,7 +566,7 @@ mod tests {
let keypair = Keypair::new(); let keypair = Keypair::new();
let program_id = Pubkey::new(&[4; 32]); let program_id = Pubkey::new(&[4; 32]);
let to = Pubkey::new(&[5; 32]); let to = Pubkey::new(&[5; 32]);
let tx = Transaction::new( let tx = Transaction::new_signed(
&keypair, &keypair,
&[keypair.pubkey(), to], &[keypair.pubkey(), to],
&program_id, &program_id,
@ -585,7 +585,7 @@ mod tests {
let keypair = Keypair::new(); let keypair = Keypair::new();
let program_id = Pubkey::new(&[4; 32]); let program_id = Pubkey::new(&[4; 32]);
let to = Pubkey::new(&[5; 32]); let to = Pubkey::new(&[5; 32]);
let tx = Transaction::new( let tx = Transaction::new_signed(
&keypair, &keypair,
&[keypair.pubkey(), to], &[keypair.pubkey(), to],
&program_id, &program_id,
@ -631,7 +631,7 @@ mod tests {
2, 2, 2, 2, 2, 2,
]); ]);
let tx = Transaction::new( let tx = Transaction::new_signed(
&keypair, &keypair,
&[to], &[to],
&program_id, &program_id,