Naming nits (#7798)

automerge
This commit is contained in:
Jack May
2020-01-14 13:38:17 -08:00
committed by Grimes
parent e6af4511a8
commit 5f4e0c7e3e
4 changed files with 20 additions and 17 deletions

View File

@ -70,17 +70,17 @@ pub trait Sysvar:
fn to_account(&self, account: &mut Account) -> Option<()> {
bincode::serialize_into(&mut account.data[..], self).ok()
}
fn from_account_info(account: &AccountInfo) -> Option<Self> {
bincode::deserialize(&account.data).ok()
fn from_account_info(account_info: &AccountInfo) -> Option<Self> {
bincode::deserialize(&account_info.data).ok()
}
fn to_account_info(&self, account: &mut AccountInfo) -> Option<()> {
bincode::serialize_into(&mut account.data[..], self).ok()
fn to_account_info(&self, account_info: &mut AccountInfo) -> Option<()> {
bincode::serialize_into(&mut account_info.data[..], self).ok()
}
fn from_keyed_account(account: &KeyedAccount) -> Result<Self, InstructionError> {
if !Self::check_id(account.unsigned_key()) {
fn from_keyed_account(keyed_account: &KeyedAccount) -> Result<Self, InstructionError> {
if !Self::check_id(keyed_account.unsigned_key()) {
return Err(InstructionError::InvalidArgument);
}
Self::from_account(account.account).ok_or(InstructionError::InvalidArgument)
Self::from_account(keyed_account.account).ok_or(InstructionError::InvalidArgument)
}
fn create_account(&self, lamports: u64) -> Account {
let data_len = Self::size_of().max(bincode::serialized_size(self).unwrap() as usize);

View File

@ -17,11 +17,14 @@ pub fn create_account(lamports: u64, rent: &Rent) -> Account {
}
pub fn verify_rent_exemption(
account: &KeyedAccount,
keyed_account: &KeyedAccount,
rent_sysvar_account: &KeyedAccount,
) -> Result<(), InstructionError> {
let rent = Rent::from_keyed_account(rent_sysvar_account)?;
if !rent.is_exempt(account.account.lamports, account.account.data.len()) {
if !rent.is_exempt(
keyed_account.account.lamports,
keyed_account.account.data.len(),
) {
Err(InstructionError::InsufficientFunds)
} else {
Ok(())