Skip to content

Commit 2a07e8c

Browse files
committed
Rename
1 parent 060a472 commit 2a07e8c

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

program/rust/src/c_oracle_header.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,25 @@ use std::mem::size_of;
1212
//things defined in bindings.h
1313
include!("../bindings.rs");
1414

15-
pub trait PythStruct: Pod {
15+
/// The PythAccount trait's purpose is to attach constants to the 3 types of accounts that Pyth has
16+
/// (mapping, price, product). This allows less duplicated code, because now we can create generic
17+
/// functions to perform common checks on the accounts and to load and initialize the accounts.
18+
pub trait PythAccount: Pod {
1619
const ACCOUNT_TYPE: u32;
1720
const INITIAL_SIZE: u32;
1821
}
1922

20-
impl PythStruct for pc_map_table_t {
23+
impl PythAccount for pc_map_table_t {
2124
const ACCOUNT_TYPE: u32 = PC_ACCTYPE_MAPPING;
2225
const INITIAL_SIZE: u32 = PC_MAP_TABLE_T_PROD_OFFSET as u32;
2326
}
2427

25-
impl PythStruct for pc_prod_t {
28+
impl PythAccount for pc_prod_t {
2629
const ACCOUNT_TYPE: u32 = PC_ACCTYPE_PRODUCT;
2730
const INITIAL_SIZE: u32 = size_of::<pc_prod_t>() as u32;
2831
}
2932

30-
impl PythStruct for pc_price_t {
33+
impl PythAccount for pc_price_t {
3134
const ACCOUNT_TYPE: u32 = PC_ACCTYPE_PRICE;
3235
const INITIAL_SIZE: u32 = PC_PRICE_T_COMP_OFFSET as u32;
3336
}

program/rust/src/rust_oracle.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use crate::c_oracle_header::{
3232
pc_price_t,
3333
pc_prod_t,
3434
pc_pub_key_t,
35-
PythStruct,
35+
PythAccount,
3636
PC_COMP_SIZE,
3737
PC_MAGIC,
3838
PC_MAP_TABLE_SIZE,
@@ -315,7 +315,7 @@ pub fn clear_account(account: &AccountInfo) -> Result<(), ProgramError> {
315315
Ok(())
316316
}
317317

318-
pub fn load_checked<'a, T: PythStruct>(
318+
pub fn load_checked<'a, T: PythAccount>(
319319
account: &'a AccountInfo,
320320
version: u32,
321321
) -> Result<RefMut<'a, T>, ProgramError> {
@@ -332,7 +332,7 @@ pub fn load_checked<'a, T: PythStruct>(
332332
load_account_as_mut::<T>(account)
333333
}
334334

335-
pub fn initialize_checked<'a, T: PythStruct>(
335+
pub fn initialize_checked<'a, T: PythAccount>(
336336
account: &'a AccountInfo,
337337
version: u32,
338338
) -> Result<RefMut<'a, T>, ProgramError> {

0 commit comments

Comments
 (0)