Revert to more consistent naming (#3114)

This commit is contained in:
Sagar Dhawan 2019-03-04 17:50:19 -08:00 committed by GitHub
parent 6d82123125
commit dc42c12f2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 19 additions and 31 deletions

View File

@ -377,7 +377,7 @@ pub fn make_active_set_entries(
let voting_keypair = VotingKeypair::new_local(active_keypair);
let vote_account_id = voting_keypair.pubkey();
let new_vote_account_tx = VoteTransaction::fund_staking_account(
let new_vote_account_tx = VoteTransaction::new_account(
active_keypair,
vote_account_id,
*blockhash,

View File

@ -155,7 +155,7 @@ impl LocalCluster {
) -> Result<()> {
// Create the vote account if necessary
if client.poll_get_balance(&vote_account).unwrap_or(0) == 0 {
let mut transaction = VoteTransaction::fund_staking_account(
let mut transaction = VoteTransaction::new_account(
from_account,
vote_account,
client.get_recent_blockhash(),

View File

@ -606,13 +606,8 @@ mod tests {
let vote_account_id = validator_vote_account_keypair.pubkey();
let blockhash = client.get_recent_blockhash();
let transaction = VoteTransaction::fund_staking_account(
&validator_keypair,
vote_account_id,
blockhash,
1,
1,
);
let transaction =
VoteTransaction::new_account(&validator_keypair, vote_account_id, blockhash, 1, 1);
let signature = client.transfer_signed(&transaction).unwrap();
client.poll_for_signature(&signature).unwrap();

View File

@ -110,13 +110,8 @@ pub mod tests {
num_tokens: u64,
) {
let blockhash = bank.last_blockhash();
let tx = VoteTransaction::fund_staking_account(
from_keypair,
*voting_pubkey,
blockhash,
num_tokens,
0,
);
let tx =
VoteTransaction::new_account(from_keypair, *voting_pubkey, blockhash, num_tokens, 0);
bank.process_transaction(&tx).unwrap();
}

View File

@ -47,7 +47,7 @@ fn create_and_fund_vote_account(
let blockhash = client.get_recent_blockhash();
info!("create_and_fund_vote_account blockhash={:?}", blockhash);
let transaction =
VoteTransaction::fund_staking_account(node_keypair, vote_account, blockhash, 1, 1);
VoteTransaction::new_account(node_keypair, vote_account, blockhash, 1, 1);
match client.transfer_signed(&transaction) {
Ok(signature) => {

View File

@ -35,8 +35,7 @@ impl<'a> RewardsBank<'a> {
lamports: u64,
) -> Result<()> {
let blockhash = self.bank.last_blockhash();
let tx =
VoteTransaction::fund_staking_account(from_keypair, vote_id, blockhash, lamports, 0);
let tx = VoteTransaction::new_account(from_keypair, vote_id, blockhash, lamports, 0);
self.bank.process_transaction(&tx)
}

View File

@ -28,8 +28,7 @@ impl<'a> VoteBank<'a> {
lamports: u64,
) -> Result<()> {
let blockhash = self.bank.last_blockhash();
let tx =
VoteTransaction::fund_staking_account(from_keypair, vote_id, blockhash, lamports, 0);
let tx = VoteTransaction::new_account(from_keypair, vote_id, blockhash, lamports, 0);
self.bank.process_transaction(&tx)
}

View File

@ -22,7 +22,7 @@ pub enum VoteInstruction {
/// * Transaction::keys[0] - the staker id that is also assumed to be the delegate by default
/// * Transaction::keys[1] - the new "vote account" to be associated with the delegate
InitializeAccount,
/// `Delegate` or `Assign` A staking account to a particular node
/// `Delegate` or `Assign` a vote account to a particular node
DelegateStake(Pubkey),
Vote(Vote),
/// Clear the credits in the vote account

View File

@ -173,7 +173,7 @@ pub fn delegate_stake(
Ok(())
}
/// Initialize the vote_state for a staking account
/// Initialize the vote_state for a vote account
/// Assumes that the account is being init as part of a account creation or balance transfer and
/// that the transaction must be signed by the staker's keys
pub fn initialize_account(keyed_accounts: &mut [KeyedAccount]) -> Result<(), ProgramError> {
@ -271,13 +271,13 @@ mod tests {
use solana_sdk::signature::{Keypair, KeypairUtil};
#[test]
fn test_initialize_staking_account() {
fn test_initialize_vote_account() {
let staker_id = Keypair::new().pubkey();
let mut staker_account = Account::new(100, 0, Pubkey::default());
let mut bogus_staker_account = Account::new(100, 0, Pubkey::default());
let staking_account_id = Keypair::new().pubkey();
let mut staking_account = create_vote_account(100);
let vote_account_id = Keypair::new().pubkey();
let mut vote_account = create_vote_account(100);
let bogus_account_id = Keypair::new().pubkey();
let mut bogus_account = Account::new(100, 0, id());
@ -297,7 +297,7 @@ mod tests {
assert_eq!(res, Err(ProgramError::InvalidUserdata));
//init should pass
keyed_accounts[1] = KeyedAccount::new(&staking_account_id, false, &mut staking_account);
keyed_accounts[1] = KeyedAccount::new(&vote_account_id, false, &mut vote_account);
let res = initialize_account(&mut keyed_accounts);
assert_eq!(res, Ok(()));

View File

@ -28,7 +28,7 @@ impl VoteTransaction {
}
/// Fund or create the staking account with tokens
pub fn fund_staking_account(
pub fn new_account(
from_keypair: &Keypair,
vote_account_id: Pubkey,
recent_blockhash: Hash,

View File

@ -254,7 +254,7 @@ impl Bank {
// Construct a vote account for the bootstrap_leader such that the leader_scheduler
// will be forced to select it as the leader for height 0
let mut bootstrap_leader_staking_account = Account {
let mut bootstrap_leader_vote_account = Account {
tokens: bootstrap_leader_stake,
userdata: vec![0; VoteState::max_size() as usize],
owner: solana_vote_api::id(),
@ -264,13 +264,13 @@ impl Bank {
let mut vote_state = VoteState::new(genesis_block.bootstrap_leader_id);
vote_state.votes.push_back(Lockout::new(&Vote::new(0)));
vote_state
.serialize(&mut bootstrap_leader_staking_account.userdata)
.serialize(&mut bootstrap_leader_vote_account.userdata)
.unwrap();
self.accounts().store_slow(
self.accounts_id,
&genesis_block.bootstrap_leader_vote_account_id,
&bootstrap_leader_staking_account,
&bootstrap_leader_vote_account,
);
self.blockhash_queue