Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions program/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ solana-program = "=1.10.29"
bytemuck = "1.11.0"
thiserror = "1.0"

[features]
debug = []

[lib]
crate-type = ["cdylib", "lib"]
8 changes: 7 additions & 1 deletion program/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
mod c_oracle_header;
mod deserialize;
mod error;
mod log;
mod processor;
mod rust_oracle;
mod time_machine_types;
Expand All @@ -16,13 +15,18 @@ mod utils;
#[cfg(test)]
mod tests;

#[cfg(feature = "debug")]
mod log;

use crate::c_oracle_header::SUCCESSFULLY_UPDATED_AGGREGATE;
use crate::error::OracleError;

#[cfg(feature = "debug")]
use crate::log::{
post_log,
pre_log,
};

use processor::process_instruction;

use solana_program::entrypoint::deserialize;
Expand Down Expand Up @@ -51,6 +55,7 @@ use solana_program::{
pub extern "C" fn entrypoint(input: *mut u8) -> u64 {
let (program_id, accounts, instruction_data) = unsafe { deserialize(input) };

#[cfg(feature = "debug")]
if let Err(error) = pre_log(&accounts, instruction_data) {
return error.into();
}
Expand All @@ -60,6 +65,7 @@ pub extern "C" fn entrypoint(input: *mut u8) -> u64 {
Ok(success_status) => success_status,
};

#[cfg(feature = "debug")]
if let Err(error) = post_log(c_ret_val, &accounts) {
return error.into();
}
Expand Down
1 change: 0 additions & 1 deletion program/rust/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ pub fn pre_log(accounts: &[AccountInfo], instruction_data: &[u8]) -> ProgramResu
Ok(())
}


pub fn post_log(c_ret_val: u64, accounts: &[AccountInfo]) -> ProgramResult {
if c_ret_val == SUCCESSFULLY_UPDATED_AGGREGATE {
// We trust that the C oracle has properly checked account 1, we can only get here through
Expand Down