@@ -2,8 +2,10 @@ use crate::c_oracle_header::*;
22use crate :: error:: OracleError ;
33use borsh:: BorshDeserialize ;
44use solana_program:: account_info:: AccountInfo ;
5+ use solana_program:: clock:: Clock ;
56use solana_program:: entrypoint:: ProgramResult ;
67use solana_program:: msg;
8+ use solana_program:: sysvar:: Sysvar ;
79use std:: mem:: size_of;
810
911pub fn pre_log ( accounts : & [ AccountInfo ] , instruction_data : & [ u8 ] ) -> ProgramResult {
@@ -14,33 +16,38 @@ pub fn pre_log(accounts: &[AccountInfo], instruction_data: &[u8]) -> ProgramResu
1416 . cmd_
1517 . try_into ( )
1618 . map_err ( |_| OracleError :: Generic ) ?;
19+
20+ let clock = Clock :: get ( ) ?;
21+
1722 match instruction_id {
1823 command_t_e_cmd_upd_price | command_t_e_cmd_agg_price => {
1924 let instruction: cmd_upd_price = cmd_upd_price:: try_from_slice ( instruction_data) ?;
2025 msg ! (
21- "UpdatePrice: publisher={:}, price_account={:}, price={:}, conf={:}, status={:}, slot={:}" ,
26+ "UpdatePrice: publisher={:}, price_account={:}, price={:}, conf={:}, status={:}, slot={:}, solana_time={:} " ,
2227 accounts. get( 0 )
2328 . ok_or( OracleError :: Generic ) ?. key,
2429 accounts. get( 1 )
2530 . ok_or( OracleError :: Generic ) ?. key,
2631 instruction. price_,
2732 instruction. conf_,
2833 instruction. status_,
29- instruction. pub_slot_
34+ instruction. pub_slot_,
35+ clock. unix_timestamp
3036 ) ;
3137 }
3238 command_t_e_cmd_upd_price_no_fail_on_error => {
3339 let instruction: cmd_upd_price = cmd_upd_price:: try_from_slice ( instruction_data) ?;
3440 msg ! (
35- "UpdatePriceNoFailOnError: publisher={:}, price_account={:}, price={:}, conf={:}, status={:}, slot={:}" ,
41+ "UpdatePriceNoFailOnError: publisher={:}, price_account={:}, price={:}, conf={:}, status={:}, slot={:}, solana_time={:} " ,
3642 accounts. get( 0 )
3743 . ok_or( OracleError :: Generic ) ?. key,
3844 accounts. get( 1 )
3945 . ok_or( OracleError :: Generic ) ?. key,
4046 instruction. price_,
4147 instruction. conf_,
4248 instruction. status_,
43- instruction. pub_slot_
49+ instruction. pub_slot_,
50+ clock. unix_timestamp
4451 ) ;
4552 }
4653 command_t_e_cmd_add_mapping => {
@@ -91,13 +98,26 @@ pub fn post_log(c_ret_val: u64, accounts: &[AccountInfo]) -> ProgramResult {
9198 . ok_or ( OracleError :: Generic ) ?
9299 . try_borrow_data ( ) ?[ start..( start + size_of :: < pc_price_info > ( ) ) ] ,
93100 ) ?;
101+
102+ let ema_info: pc_ema = pc_ema:: try_from_slice (
103+ & accounts
104+ . get ( 1 )
105+ . ok_or ( OracleError :: Generic ) ?
106+ . try_borrow_data ( ) ?[ start..( start + size_of :: < pc_ema > ( ) ) ] ,
107+ ) ?;
108+
109+ let clock = Clock :: get ( ) ?;
110+
94111 msg ! (
95- "UpdateAggregate : price_account={:}, price={:}, conf={:}, status={:}, slot={:}" ,
96- accounts. get( 1 ) . ok_or( OracleError :: Generic ) ?. key,
112+ "UpdateAggregate : price_account={:}, price={:}, conf={:}, status={:}, slot={:}, solana_time={:}, ema={:}" ,
113+ accounts. get( 1 )
114+ . ok_or( OracleError :: Generic ) ?. key,
97115 aggregate_price_info. price_,
98116 aggregate_price_info. conf_,
99117 aggregate_price_info. status_,
100- aggregate_price_info. pub_slot_
118+ aggregate_price_info. pub_slot_,
119+ clock. unix_timestamp,
120+ ema_info. val_
101121 ) ;
102122 }
103123 Ok ( ( ) )
0 commit comments