Move fn to sdk
This commit is contained in:
committed by
Michael Vines
parent
f929301c60
commit
7e17a0d3bb
@ -14,7 +14,7 @@ use solana_sdk::{
|
|||||||
account_utils::{State, StateMut},
|
account_utils::{State, StateMut},
|
||||||
clock::{Clock, Epoch, UnixTimestamp},
|
clock::{Clock, Epoch, UnixTimestamp},
|
||||||
ic_msg,
|
ic_msg,
|
||||||
instruction::InstructionError,
|
instruction::{checked_add, InstructionError},
|
||||||
keyed_account::KeyedAccount,
|
keyed_account::KeyedAccount,
|
||||||
process_instruction::InvokeContext,
|
process_instruction::InvokeContext,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
@ -70,13 +70,6 @@ impl Default for StakeState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn checked_add(a: u64, b: u64) -> Result<u64, InstructionError> {
|
|
||||||
match a.checked_add(b) {
|
|
||||||
Some(sum) => Ok(sum),
|
|
||||||
None => Err(InstructionError::InsufficientFunds),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl StakeState {
|
impl StakeState {
|
||||||
pub fn get_rent_exempt_reserve(rent: &Rent) -> u64 {
|
pub fn get_rent_exempt_reserve(rent: &Rent) -> u64 {
|
||||||
rent.minimum_balance(std::mem::size_of::<StakeState>())
|
rent.minimum_balance(std::mem::size_of::<StakeState>())
|
||||||
|
@ -209,6 +209,13 @@ impl Instruction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn checked_add(a: u64, b: u64) -> Result<u64, InstructionError> {
|
||||||
|
match a.checked_add(b) {
|
||||||
|
Some(sum) => Ok(sum),
|
||||||
|
None => Err(InstructionError::InsufficientFunds),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Account metadata used to define Instructions
|
/// Account metadata used to define Instructions
|
||||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
|
||||||
pub struct AccountMeta {
|
pub struct AccountMeta {
|
||||||
|
Reference in New Issue
Block a user