Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions program/rust/src/rust_oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::c_oracle_header::{
PriceEma,
PriceInfo,
ProductAccount,
PythAccount,
MAX_CI_DIVISOR,
PC_COMP_SIZE,
PC_MAP_TABLE_SIZE,
Expand Down Expand Up @@ -60,9 +61,6 @@ use solana_program::system_instruction::transfer;
use solana_program::system_program::check_id;
use solana_program::sysvar::Sysvar;

const PRICE_T_SIZE: usize = size_of::<PriceAccount>();
const PRICE_ACCOUNT_SIZE: usize = size_of::<PriceAccountWrapper>();


#[cfg(target_arch = "bpf")]
#[link(name = "cpyth-bpf")]
Expand Down Expand Up @@ -116,7 +114,7 @@ pub fn resize_price_account(
}
let account_len = price_account_info.try_data_len()?;
match account_len {
PRICE_T_SIZE => {
PriceAccount::MINIMUM_SIZE => {
// Ensure account is still rent exempt after resizing
let rent: Rent = Default::default();
let lamports_needed: u64 = rent
Expand All @@ -142,7 +140,7 @@ pub fn resize_price_account(
price_account.initialize_time_machine()?;
Ok(())
}
PRICE_ACCOUNT_SIZE => Ok(()),
PriceAccountWrapper::MINIMUM_SIZE => Ok(()),
_ => Err(ProgramError::InvalidArgument),
}
}
Expand Down Expand Up @@ -264,7 +262,7 @@ pub fn upd_price(
}

let account_len = price_account.try_data_len()?;
if aggregate_updated && account_len == PRICE_ACCOUNT_SIZE {
if aggregate_updated && account_len == PriceAccountWrapper::MINIMUM_SIZE {
let mut price_account =
load_checked::<PriceAccountWrapper>(price_account, cmd_args.header.version)?;
price_account.add_price_to_time_machine()?;
Expand Down