Rename userdata to data (#3282)

* Rename userdata to data

Instead of saying "userdata", which is ambiguous and imprecise,
say "instruction data" or "account data".

Also, add `ProgramError::InvalidInstructionData`

Fixes #2761
This commit is contained in:
Greg Fitzgerald
2019-03-14 10:48:27 -06:00
committed by GitHub
parent de13082347
commit c1eec0290e
42 changed files with 245 additions and 254 deletions

View File

@@ -22,7 +22,7 @@ fn entrypoint(
trace!("process_instruction: {:?}", data);
trace!("keyed_accounts: {:?}", keyed_accounts);
match deserialize(data).map_err(|_| ProgramError::InvalidUserdata)? {
match deserialize(data).map_err(|_| ProgramError::InvalidInstructionData)? {
VoteInstruction::InitializeAccount => vote_state::initialize_account(keyed_accounts),
VoteInstruction::DelegateStake(delegate_id) => {
vote_state::delegate_stake(keyed_accounts, &delegate_id)

View File

@@ -64,7 +64,7 @@ impl<'a> VoteBank<'a> {
self.bank.register_tick(&hash(blockhash.as_ref()));
let vote_account = self.bank.get_account(&vote_keypair.pubkey()).unwrap();
Ok(VoteState::deserialize(&vote_account.userdata).unwrap())
Ok(VoteState::deserialize(&vote_account.data).unwrap())
}
}
@@ -129,7 +129,7 @@ fn test_vote_via_bank_with_no_signature() {
// And ensure there's no vote.
let vote_account = bank.get_account(&vote_id).unwrap();
let vote_state = VoteState::deserialize(&vote_account.userdata).unwrap();
let vote_state = VoteState::deserialize(&vote_account.data).unwrap();
assert_eq!(vote_state.votes.len(), 0);
assert_eq!(