Skip to content

Commit 6b539db

Browse files
committed
refactor
1 parent 144bf94 commit 6b539db

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

program/rust/src/processor/upd_price.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use {
22
crate::{
33
accounts::{
44
PriceAccount,
5-
PriceInfo,
65
PythOracleSerialize,
76
UPD_PRICE_WRITE_SEED,
87
},
@@ -129,7 +128,6 @@ pub fn upd_price(
129128
let clock = Clock::from_account_info(clock_account)?;
130129

131130
let mut publisher_index: usize = 0;
132-
let latest_aggregate_price: PriceInfo;
133131
let slots_since_last_update: u64;
134132
let noninitial_price_update_after_program_upgrade: bool;
135133

@@ -162,10 +160,6 @@ pub fn upd_price(
162160
noninitial_price_update_after_program_upgrade =
163161
price_data.prev_twap_.denom_ == 0 && slots_since_last_update == 0;
164162

165-
// We assign the current aggregate price to latest_aggregate_price before calling c_upd_aggregate because
166-
// c_upd_aggregate directly modifies the memory of price_data.agg_ to update its values. This is crucial for
167-
// comparisons or operations that rely on the aggregate price state before the update such as slots_since_last_update.
168-
latest_aggregate_price = price_data.agg_;
169163
let latest_publisher_price = price_data.comp_[publisher_index].latest_;
170164

171165
// Check that publisher is publishing a more recent price
@@ -196,7 +190,7 @@ pub fn upd_price(
196190
}
197191

198192
// If the price update is the first in the slot and the aggregate is trading, update the previous slot, price, conf, and timestamp.
199-
if slots_since_last_update > 0 && latest_aggregate_price.status_ == PC_STATUS_TRADING {
193+
if slots_since_last_update > 0 && price_data.agg_.status_ == PC_STATUS_TRADING {
200194
price_data.prev_slot_ = price_data.agg_.pub_slot_;
201195
price_data.prev_price_ = price_data.agg_.price_;
202196
price_data.prev_conf_ = price_data.agg_.conf_;

0 commit comments

Comments
 (0)