pass Pubkeys as refs, copy only where values needed (#3213)

* pass Pubkeys as refs, copy only where values needed

* Pubkey is pervasive

* fixup
This commit is contained in:
Rob Walker
2019-03-09 19:28:43 -08:00
committed by GitHub
parent ac226c3e14
commit 195a880576
89 changed files with 864 additions and 828 deletions

View File

@@ -9,11 +9,11 @@ pub enum RewardsInstruction {
}
impl RewardsInstruction {
pub fn new_redeem_vote_credits(vote_id: Pubkey, rewards_id: Pubkey) -> BuilderInstruction {
pub fn new_redeem_vote_credits(vote_id: &Pubkey, rewards_id: &Pubkey) -> BuilderInstruction {
BuilderInstruction::new(
id(),
&RewardsInstruction::RedeemVoteCredits,
vec![(vote_id, true), (rewards_id, false)],
vec![(*vote_id, true), (*rewards_id, false)],
)
}
}

View File

@@ -17,7 +17,7 @@ pub struct RewardsTransaction {}
impl RewardsTransaction {
pub fn new_account(
from_keypair: &Keypair,
rewards_id: Pubkey,
rewards_id: &Pubkey,
blockhash: Hash,
lamports: u64,
fee: u64,
@@ -28,23 +28,23 @@ impl RewardsTransaction {
blockhash,
lamports,
RewardsState::max_size() as u64,
id(),
&id(),
fee,
)
}
pub fn new_redeem_credits(
vote_keypair: &Keypair,
rewards_id: Pubkey,
rewards_id: &Pubkey,
blockhash: Hash,
fee: u64,
) -> Transaction {
let vote_id = vote_keypair.pubkey();
TransactionBuilder::new(fee)
.push(RewardsInstruction::new_redeem_vote_credits(
vote_id, rewards_id,
&vote_id, rewards_id,
))
.push(VoteInstruction::new_clear_credits(vote_id))
.push(VoteInstruction::new_clear_credits(&vote_id))
.sign(&[vote_keypair], blockhash)
}
}