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

Don't use move semantics if not needed (bp #8793) #8803

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 2 additions & 3 deletions archiver-lib/src/archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,7 @@ impl Archiver {
&archiver_keypair.pubkey(),
&storage_keypair.pubkey(),
);
let message =
Message::new_with_payer(vec![ix], Some(&archiver_keypair.pubkey()));
let message = Message::new_with_payer(&[ix], Some(&archiver_keypair.pubkey()));
if let Err(e) = client.send_message(&[archiver_keypair.as_ref()], message) {
error!("unable to redeem reward, tx failed: {:?}", e);
} else {
Expand Down Expand Up @@ -655,7 +654,7 @@ impl Archiver {
Signature::new(&meta.signature.as_ref()),
meta.blockhash,
);
let message = Message::new_with_payer(vec![instruction], Some(&archiver_keypair.pubkey()));
let message = Message::new_with_payer(&[instruction], Some(&archiver_keypair.pubkey()));
let mut transaction = Transaction::new(
&[archiver_keypair.as_ref(), storage_keypair.as_ref()],
message,
Expand Down
20 changes: 10 additions & 10 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ fn process_deploy(
program_data.len() as u64,
&bpf_loader::id(),
);
let message = Message::new(vec![ix]);
let message = Message::new(&[ix]);
let mut create_account_tx = Transaction::new_unsigned(message);
create_account_tx.try_sign(&[config.signers[0], &program_id], blockhash)?;
messages.push(&create_account_tx.message);
Expand All @@ -1216,7 +1216,7 @@ fn process_deploy(
(i * DATA_CHUNK_SIZE) as u32,
chunk.to_vec(),
);
let message = Message::new_with_payer(vec![instruction], Some(&signers[0].pubkey()));
let message = Message::new_with_payer(&[instruction], Some(&signers[0].pubkey()));
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&signers, blockhash)?;
write_transactions.push(tx);
Expand All @@ -1226,7 +1226,7 @@ fn process_deploy(
}

let instruction = loader_instruction::finalize(&program_id.pubkey(), &bpf_loader::id());
let message = Message::new_with_payer(vec![instruction], Some(&signers[0].pubkey()));
let message = Message::new_with_payer(&[instruction], Some(&signers[0].pubkey()));
let mut finalize_tx = Transaction::new_unsigned(message);
finalize_tx.try_sign(&signers, blockhash)?;
messages.push(&finalize_tx.message);
Expand Down Expand Up @@ -1294,7 +1294,7 @@ fn process_pay(
let message = if let Some(nonce_account) = &nonce_account {
Message::new_with_nonce(vec![ix], None, nonce_account, &nonce_authority.pubkey())
} else {
Message::new(vec![ix])
Message::new(&[ix])
};
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, blockhash)?;
Expand Down Expand Up @@ -1334,7 +1334,7 @@ fn process_pay(
cancelable,
lamports,
);
let message = Message::new(ixs);
let message = Message::new(&ixs);
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&[config.signers[0], &contract_state], blockhash)?;
if sign_only {
Expand Down Expand Up @@ -1377,7 +1377,7 @@ fn process_pay(
cancelable,
lamports,
);
let message = Message::new(ixs);
let message = Message::new(&ixs);
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&[config.signers[0], &contract_state], blockhash)?;
if sign_only {
Expand Down Expand Up @@ -1411,7 +1411,7 @@ fn process_cancel(rpc_client: &RpcClient, config: &CliConfig, pubkey: &Pubkey) -
pubkey,
&config.signers[0].pubkey(),
);
let message = Message::new(vec![ix]);
let message = Message::new(&[ix]);
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, blockhash)?;
check_account_for_fee(
Expand All @@ -1434,7 +1434,7 @@ fn process_time_elapsed(
let (blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?;

let ix = budget_instruction::apply_timestamp(&config.signers[0].pubkey(), pubkey, to, dt);
let message = Message::new(vec![ix]);
let message = Message::new(&[ix]);
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, blockhash)?;
check_account_for_fee(
Expand Down Expand Up @@ -1482,7 +1482,7 @@ fn process_transfer(
&nonce_authority.pubkey(),
)
} else {
Message::new_with_payer(ixs, Some(&fee_payer.pubkey()))
Message::new_with_payer(&ixs, Some(&fee_payer.pubkey()))
};
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;
Expand Down Expand Up @@ -1514,7 +1514,7 @@ fn process_witness(
let (blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?;

let ix = budget_instruction::apply_signature(&config.signers[0].pubkey(), pubkey, to);
let message = Message::new(vec![ix]);
let message = Message::new(&[ix]);
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, blockhash)?;
check_account_for_fee(
Expand Down
2 changes: 1 addition & 1 deletion cli/src/cluster_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ pub fn process_ping(
last_blockhash = recent_blockhash;

let ix = system_instruction::transfer(&config.signers[0].pubkey(), &to, lamports);
let message = Message::new(vec![ix]);
let message = Message::new(&[ix]);
let mut transaction = Transaction::new_unsigned(message);
transaction.try_sign(&config.signers, recent_blockhash)?;
check_account_for_fee(
Expand Down
8 changes: 4 additions & 4 deletions cli/src/nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ pub fn process_authorize_nonce_account(

let nonce_authority = config.signers[nonce_authority];
let ix = authorize_nonce_account(nonce_account, &nonce_authority.pubkey(), new_authority);
let message = Message::new_with_payer(vec![ix], Some(&config.signers[0].pubkey()));
let message = Message::new_with_payer(&[ix], Some(&config.signers[0].pubkey()));
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;

Expand Down Expand Up @@ -518,7 +518,7 @@ pub fn process_create_nonce_account(

let (recent_blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?;

let message = Message::new_with_payer(ixs, Some(&config.signers[0].pubkey()));
let message = Message::new_with_payer(&ixs, Some(&config.signers[0].pubkey()));
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;

Expand Down Expand Up @@ -560,7 +560,7 @@ pub fn process_new_nonce(
let nonce_authority = config.signers[nonce_authority];
let ix = advance_nonce_account(&nonce_account, &nonce_authority.pubkey());
let (recent_blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?;
let message = Message::new_with_payer(vec![ix], Some(&config.signers[0].pubkey()));
let message = Message::new_with_payer(&[ix], Some(&config.signers[0].pubkey()));
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;
check_account_for_fee(
Expand Down Expand Up @@ -633,7 +633,7 @@ pub fn process_withdraw_from_nonce_account(
destination_account_pubkey,
lamports,
);
let message = Message::new_with_payer(vec![ix], Some(&config.signers[0].pubkey()));
let message = Message::new_with_payer(&[ix], Some(&config.signers[0].pubkey()));
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;
check_account_for_fee(
Expand Down
14 changes: 7 additions & 7 deletions cli/src/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ pub fn process_create_stake_account(
&nonce_authority.pubkey(),
)
} else {
Message::new_with_payer(ixs, Some(&fee_payer.pubkey()))
Message::new_with_payer(&ixs, Some(&fee_payer.pubkey()))
};
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;
Expand Down Expand Up @@ -889,7 +889,7 @@ pub fn process_stake_authorize(
&nonce_authority.pubkey(),
)
} else {
Message::new_with_payer(ixs, Some(&fee_payer.pubkey()))
Message::new_with_payer(&ixs, Some(&fee_payer.pubkey()))
};
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;
Expand Down Expand Up @@ -942,7 +942,7 @@ pub fn process_deactivate_stake_account(
&nonce_authority.pubkey(),
)
} else {
Message::new_with_payer(ixs, Some(&fee_payer.pubkey()))
Message::new_with_payer(&ixs, Some(&fee_payer.pubkey()))
};
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;
Expand Down Expand Up @@ -1001,7 +1001,7 @@ pub fn process_withdraw_stake(
&nonce_authority.pubkey(),
)
} else {
Message::new_with_payer(ixs, Some(&fee_payer.pubkey()))
Message::new_with_payer(&ixs, Some(&fee_payer.pubkey()))
};
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;
Expand Down Expand Up @@ -1134,7 +1134,7 @@ pub fn process_split_stake(
&nonce_authority.pubkey(),
)
} else {
Message::new_with_payer(ixs, Some(&fee_payer.pubkey()))
Message::new_with_payer(&ixs, Some(&fee_payer.pubkey()))
};
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;
Expand Down Expand Up @@ -1190,7 +1190,7 @@ pub fn process_stake_set_lockup(
&nonce_authority.pubkey(),
)
} else {
Message::new_with_payer(ixs, Some(&fee_payer.pubkey()))
Message::new_with_payer(&ixs, Some(&fee_payer.pubkey()))
};
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;
Expand Down Expand Up @@ -1424,7 +1424,7 @@ pub fn process_delegate_stake(
&nonce_authority.pubkey(),
)
} else {
Message::new_with_payer(ixs, Some(&fee_payer.pubkey()))
Message::new_with_payer(&ixs, Some(&fee_payer.pubkey()))
};
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;
Expand Down
4 changes: 2 additions & 2 deletions cli/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub fn process_create_storage_account(
);
let (recent_blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?;

let message = Message::new(ixs);
let message = Message::new(&ixs);
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;
check_account_for_fee(
Expand All @@ -236,7 +236,7 @@ pub fn process_claim_storage_reward(
let instruction =
storage_instruction::claim_reward(node_account_pubkey, storage_account_pubkey);
let signers = [config.signers[0]];
let message = Message::new_with_payer(vec![instruction], Some(&signers[0].pubkey()));
let message = Message::new_with_payer(&[instruction], Some(&signers[0].pubkey()));
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&signers, recent_blockhash)?;
check_account_for_fee(
Expand Down
4 changes: 2 additions & 2 deletions cli/src/validator_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ pub fn process_set_validator_info(
&validator_info,
)]);
let signers = vec![config.signers[0], &info_keypair];
let message = Message::new(instructions);
let message = Message::new(&instructions);
(message, signers)
} else {
println!(
Expand All @@ -353,7 +353,7 @@ pub fn process_set_validator_info(
keys,
&validator_info,
)];
let message = Message::new_with_payer(instructions, Some(&config.signers[0].pubkey()));
let message = Message::new_with_payer(&instructions, Some(&config.signers[0].pubkey()));
let signers = vec![config.signers[0]];
(message, signers)
};
Expand Down
6 changes: 3 additions & 3 deletions cli/src/vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ pub fn process_create_vote_account(
};
let (recent_blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?;

let message = Message::new(ixs);
let message = Message::new(&ixs);
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;
check_account_for_fee(
Expand Down Expand Up @@ -391,7 +391,7 @@ pub fn process_vote_authorize(
vote_authorize, // vote or withdraw
)];

let message = Message::new_with_payer(ixs, Some(&config.signers[0].pubkey()));
let message = Message::new_with_payer(&ixs, Some(&config.signers[0].pubkey()));
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;
check_account_for_fee(
Expand Down Expand Up @@ -422,7 +422,7 @@ pub fn process_vote_update_validator(
new_identity_pubkey,
)];

let message = Message::new_with_payer(ixs, Some(&config.signers[0].pubkey()));
let message = Message::new_with_payer(&ixs, Some(&config.signers[0].pubkey()));
let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, recent_blockhash)?;
check_account_for_fee(
Expand Down
4 changes: 2 additions & 2 deletions client/src/thin_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ impl SyncClient for ThinClient {
keypair: &Keypair,
instruction: Instruction,
) -> TransportResult<Signature> {
let message = Message::new(vec![instruction]);
let message = Message::new(&[instruction]);
self.send_message(&[keypair], message)
}

Expand Down Expand Up @@ -596,7 +596,7 @@ impl AsyncClient for ThinClient {
instruction: Instruction,
recent_blockhash: Hash,
) -> io::Result<Signature> {
let message = Message::new(vec![instruction]);
let message = Message::new(&[instruction]);
self.async_send_message(&[keypair], message, recent_blockhash)
}
fn async_transfer(
Expand Down
2 changes: 1 addition & 1 deletion core/src/storage_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl StorageStage {
}

let signer_keys = vec![keypair.as_ref(), storage_keypair.as_ref()];
let message = Message::new_with_payer(vec![instruction], Some(&signer_keys[0].pubkey()));
let message = Message::new_with_payer(&[instruction], Some(&signer_keys[0].pubkey()));
let transaction = Transaction::new(&signer_keys, message, blockhash);
// try sending the transaction upto 5 times
for _ in 0..5 {
Expand Down
2 changes: 1 addition & 1 deletion core/tests/storage_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ mod tests {
None,
)
.unwrap();
let message = Message::new_with_payer(vec![mining_proof_ix], Some(&mint_keypair.pubkey()));
let message = Message::new_with_payer(&[mining_proof_ix], Some(&mint_keypair.pubkey()));
let mining_proof_tx = Transaction::new(
&[&mint_keypair, archiver_keypair.as_ref()],
message,
Expand Down
4 changes: 2 additions & 2 deletions faucet/src/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl Faucet {

let create_instruction =
system_instruction::transfer(&self.mint_keypair.pubkey(), &to, lamports);
let message = Message::new(vec![create_instruction]);
let message = Message::new(&[create_instruction]);
Ok(Transaction::new(&[&self.mint_keypair], message, blockhash))
} else {
Err(Error::new(
Expand Down Expand Up @@ -413,7 +413,7 @@ mod tests {

let keypair = Keypair::new();
let expected_instruction = system_instruction::transfer(&keypair.pubkey(), &to, lamports);
let message = Message::new(vec![expected_instruction]);
let message = Message::new(&[expected_instruction]);
let expected_tx = Transaction::new(&[&keypair], message, blockhash);
let expected_bytes = serialize(&expected_tx).unwrap();
let mut expected_vec_with_length = vec![0; 2];
Expand Down
2 changes: 1 addition & 1 deletion faucet/tests/local-faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn test_local_faucet() {
let lamports = 50;
let blockhash = Hash::new(&to.as_ref());
let create_instruction = system_instruction::transfer(&keypair.pubkey(), &to, lamports);
let message = Message::new(vec![create_instruction]);
let message = Message::new(&[create_instruction]);
let expected_tx = Transaction::new(&[&keypair], message, blockhash);

let (sender, receiver) = channel();
Expand Down
2 changes: 1 addition & 1 deletion install/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ fn store_update_manifest(
update_manifest,
);

let message = Message::new_with_payer(vec![instruction], Some(&from_keypair.pubkey()));
let message = Message::new_with_payer(&[instruction], Some(&from_keypair.pubkey()));
let mut transaction = Transaction::new(&signers, message, recent_blockhash);
rpc_client.send_and_confirm_transaction(&mut transaction, &[from_keypair])?;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion keygen/src/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
}
("verify", Some(matches)) => {
let keypair = get_keypair_from_matches(matches, config, wallet_manager)?;
let simple_message = Message::new(vec![Instruction::new(
let simple_message = Message::new(&[Instruction::new(
Pubkey::default(),
&0,
vec![AccountMeta::new(keypair.pubkey(), true)],
Expand Down
3 changes: 1 addition & 2 deletions ledger/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,7 @@ mod tests {
fn test_verify_tick_hash_count() {
let hashes_per_tick = 10;
let keypairs: Vec<&Keypair> = Vec::new();
let tx: Transaction =
Transaction::new(&keypairs, Message::new(Vec::new()), Hash::default());
let tx: Transaction = Transaction::new(&keypairs, Message::new(&[]), Hash::default());
let tx_entry = Entry::new(&Hash::default(), 1, vec![tx]);
let full_tick_entry = Entry::new_tick(hashes_per_tick, &Hash::default());
let partial_tick_entry = Entry::new_tick(hashes_per_tick - 1, &Hash::default());
Expand Down
2 changes: 1 addition & 1 deletion local-cluster/src/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ impl LocalCluster {
StorageAccountType::Validator
};
let message = Message::new_with_payer(
storage_instruction::create_storage_account(
&storage_instruction::create_storage_account(
&from_keypair.pubkey(),
&from_keypair.pubkey(),
&storage_keypair.pubkey(),
Expand Down
Loading