From 52bc4a359869580a709450649237351a097004bb Mon Sep 17 00:00:00 2001 From: Jack May Date: Mon, 20 Jan 2020 15:27:36 -0800 Subject: [PATCH] nudge (#7887) --- sdk/src/account.rs | 14 +++++++------- sdk/src/instruction.rs | 2 +- sdk/src/instruction_processor_utils.rs | 14 +++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sdk/src/account.rs b/sdk/src/account.rs index 7dd9b24b5d..f03550132d 100644 --- a/sdk/src/account.rs +++ b/sdk/src/account.rs @@ -61,12 +61,12 @@ impl fmt::Debug for Account { } impl Account { - pub fn new(lamports: u64, space: usize, owner: &Pubkey) -> Account { - Account { + pub fn new(lamports: u64, space: usize, owner: &Pubkey) -> Self { + Self { lamports, data: vec![0u8; space], owner: *owner, - ..Account::default() + ..Self::default() } } @@ -74,13 +74,13 @@ impl Account { lamports: u64, state: &T, owner: &Pubkey, - ) -> Result { + ) -> Result { let data = bincode::serialize(state)?; - Ok(Account { + Ok(Self { lamports, data, owner: *owner, - ..Account::default() + ..Self::default() }) } @@ -89,7 +89,7 @@ impl Account { state: &T, space: usize, owner: &Pubkey, - ) -> Result { + ) -> Result { let mut account = Self::new(lamports, space, owner); account.serialize_data(state)?; diff --git a/sdk/src/instruction.rs b/sdk/src/instruction.rs index 6adab5b8ac..ecb597fe60 100644 --- a/sdk/src/instruction.rs +++ b/sdk/src/instruction.rs @@ -73,7 +73,7 @@ pub enum InstructionError { /// A non-system program changed the size of the account data AccountDataSizeChanged, - /// the instruction expected an executable account + /// The instruction expected an executable account AccountNotExecutable, /// CustomError allows on-chain programs to implement program-specific error types and see diff --git a/sdk/src/instruction_processor_utils.rs b/sdk/src/instruction_processor_utils.rs index 476bac6c96..b8bbbae59d 100644 --- a/sdk/src/instruction_processor_utils.rs +++ b/sdk/src/instruction_processor_utils.rs @@ -5,7 +5,7 @@ use num_traits::{FromPrimitive, ToPrimitive}; pub type Entrypoint = unsafe extern "C" fn( program_id: &Pubkey, keyed_accounts: &mut [KeyedAccount], - data: &[u8], + instruction_data: &[u8], ) -> Result<(), InstructionError>; /// Convenience macro to declare a native program @@ -29,7 +29,7 @@ pub type Entrypoint = unsafe extern "C" fn( /// fn my_process_instruction( /// program_id: &Pubkey, /// keyed_accounts: &mut [KeyedAccount], -/// data: &[u8], +/// instruction_data: &[u8], /// ) -> Result<(), InstructionError> { /// // Process an instruction /// Ok(()) @@ -60,7 +60,7 @@ pub type Entrypoint = unsafe extern "C" fn( /// fn my_process_instruction( /// program_id: &Pubkey, /// keyed_accounts: &mut [KeyedAccount], -/// data: &[u8], +/// instruction_data: &[u8], /// ) -> Result<(), InstructionError> { /// // Process an instruction /// Ok(()) @@ -92,9 +92,9 @@ macro_rules! declare_program( pub extern "C" fn $name( program_id: &$crate::pubkey::Pubkey, keyed_accounts: &mut [$crate::account::KeyedAccount], - data: &[u8], + instruction_data: &[u8], ) -> Result<(), $crate::instruction::InstructionError> { - $entrypoint(program_id, keyed_accounts, data) + $entrypoint(program_id, keyed_accounts, instruction_data) } ) ); @@ -119,14 +119,14 @@ pub fn is_executable(keyed_accounts: &[KeyedAccount]) -> bool { !keyed_accounts.is_empty() && keyed_accounts[0].account.executable } -pub fn limited_deserialize(data: &[u8]) -> Result +pub fn limited_deserialize(instruction_data: &[u8]) -> Result where T: serde::de::DeserializeOwned, { let limit = crate::packet::PACKET_DATA_SIZE as u64; bincode::config() .limit(limit) - .deserialize(data) + .deserialize(instruction_data) .map_err(|_| InstructionError::InvalidInstructionData) }