Skip to content

Commit 905172a

Browse files
committed
Add expo
1 parent 8410e80 commit 905172a

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

program/rust/src/log.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,28 @@ pub fn pre_log(accounts: &[AccountInfo], instruction_data: &[u8]) -> ProgramResu
1919

2020
let clock = Clock::get()?;
2121

22+
let expo_start : usize = PRICE_T_EXPO_OFFSET.try_into()
23+
.map_err(|_| OracleError::Generic)?;
24+
25+
let expo: i32 = i32::try_from_slice(
26+
&accounts
27+
.get(1)
28+
.ok_or(OracleError::Generic)?
29+
.try_borrow_data()?[expo_start..(expo_start + size_of::<i32>())],
30+
)?;
31+
2232
match instruction_id {
2333
command_t_e_cmd_upd_price | command_t_e_cmd_agg_price => {
2434
let instruction: cmd_upd_price = cmd_upd_price::try_from_slice(instruction_data)?;
2535
msg!(
26-
"UpdatePrice: publisher={:}, price_account={:}, price={:}, conf={:}, status={:}, slot={:}, solana_time={:}",
36+
"UpdatePrice: publisher={:}, price_account={:}, price={:}, conf={:}, expo={:}, status={:}, slot={:}, solana_time={:}",
2737
accounts.get(0)
2838
.ok_or(OracleError::Generic)?.key,
2939
accounts.get(1)
3040
.ok_or(OracleError::Generic)?.key,
3141
instruction.price_,
3242
instruction.conf_,
43+
expo,
3344
instruction.status_,
3445
instruction.pub_slot_,
3546
clock.unix_timestamp
@@ -38,13 +49,14 @@ pub fn pre_log(accounts: &[AccountInfo], instruction_data: &[u8]) -> ProgramResu
3849
command_t_e_cmd_upd_price_no_fail_on_error => {
3950
let instruction: cmd_upd_price = cmd_upd_price::try_from_slice(instruction_data)?;
4051
msg!(
41-
"UpdatePriceNoFailOnError: publisher={:}, price_account={:}, price={:}, conf={:}, status={:}, slot={:}, solana_time={:}",
52+
"UpdatePriceNoFailOnError: publisher={:}, price_account={:}, price={:}, conf={:}, expo={:}, status={:}, slot={:}, solana_time={:}",
4253
accounts.get(0)
4354
.ok_or(OracleError::Generic)?.key,
4455
accounts.get(1)
4556
.ok_or(OracleError::Generic)?.key,
4657
instruction.price_,
4758
instruction.conf_,
59+
expo,
4860
instruction.status_,
4961
instruction.pub_slot_,
5062
clock.unix_timestamp
@@ -110,14 +122,25 @@ pub fn post_log(c_ret_val: u64, accounts: &[AccountInfo]) -> ProgramResult {
110122
.try_borrow_data()?[ema_start..(ema_start + size_of::<pc_ema>())],
111123
)?;
112124

125+
let expo_start : usize = PRICE_T_EXPO_OFFSET.try_into()
126+
.map_err(|_| OracleError::Generic)?;
127+
128+
let expo: i32 = i32::try_from_slice(
129+
&accounts
130+
.get(1)
131+
.ok_or(OracleError::Generic)?
132+
.try_borrow_data()?[expo_start..(expo_start + size_of::<i32>())],
133+
)?;
134+
113135
let clock = Clock::get()?;
114136

115137
msg!(
116-
"UpdateAggregate : price_account={:}, price={:}, conf={:}, status={:}, slot={:}, solana_time={:}, ema={:}",
138+
"UpdateAggregate : price_account={:}, price={:}, conf={:}, expo={:}, status={:}, slot={:}, solana_time={:}, ema={:}",
117139
accounts.get(1)
118140
.ok_or(OracleError::Generic)?.key,
119141
aggregate_price_info.price_,
120142
aggregate_price_info.conf_,
143+
expo,
121144
aggregate_price_info.status_,
122145
aggregate_price_info.pub_slot_,
123146
clock.unix_timestamp,

0 commit comments

Comments
 (0)