@@ -164,22 +164,28 @@ impl PythReceiver {
164
164
// dummy implementation
165
165
}
166
166
167
- fn update_price_feeds_internal ( & mut self , update_data : Vec < u8 > , price_ids : Vec < [ u8 ; 32 ] > , min_publish_time : u64 , max_publish_time : u64 , unique : bool ) -> Result < ( ) , PythReceiverError > {
168
- let price_returns= self . parse_price_feed_updates ( update_data, price_ids. clone ( ) , min_publish_time, max_publish_time) ?;
169
- for i in 0 ..price_ids. clone ( ) . len ( ) {
170
- let cur_price_id = & price_ids[ i] ;
171
- let cur_price_return = & price_returns[ i] ;
172
- let price_id_fb : FixedBytes < 32 > = FixedBytes :: from ( cur_price_id) ;
167
+ fn update_price_feeds_internal ( & mut self , update_data : Vec < u8 > , _price_ids : Vec < [ u8 ; 32 ] > , min_publish_time : u64 , max_publish_time : u64 , _unique : bool ) -> Result < ( ) , PythReceiverError > {
168
+ let price_pairs = self . parse_price_feed_updates_internal (
169
+ update_data,
170
+ min_publish_time,
171
+ max_publish_time,
172
+ false , // check_uniqueness
173
+ false , // check_update_data_is_minimal
174
+ true , // store_updates_if_fresh
175
+ ) ?;
176
+
177
+ for ( price_id, price_return) in price_pairs {
178
+ let price_id_fb: FixedBytes < 32 > = FixedBytes :: from ( price_id) ;
173
179
let mut recent_price_info = self . latest_price_info . setter ( price_id_fb) ;
174
180
175
- if recent_price_info. publish_time . get ( ) < cur_price_return . 0
181
+ if recent_price_info. publish_time . get ( ) < price_return . 0
176
182
|| recent_price_info. price . get ( ) == I64 :: ZERO {
177
- recent_price_info. publish_time . set ( cur_price_return . 0 ) ;
178
- recent_price_info. expo . set ( cur_price_return . 1 ) ;
179
- recent_price_info. price . set ( cur_price_return . 2 ) ;
180
- recent_price_info. conf . set ( cur_price_return . 3 ) ;
181
- recent_price_info. ema_price . set ( cur_price_return . 4 ) ;
182
- recent_price_info. ema_conf . set ( cur_price_return . 5 ) ;
183
+ recent_price_info. publish_time . set ( price_return . 0 ) ;
184
+ recent_price_info. expo . set ( price_return . 1 ) ;
185
+ recent_price_info. price . set ( price_return . 2 ) ;
186
+ recent_price_info. conf . set ( price_return . 3 ) ;
187
+ recent_price_info. ema_price . set ( price_return . 4 ) ;
188
+ recent_price_info. ema_conf . set ( price_return . 5 ) ;
183
189
}
184
190
}
185
191
@@ -316,16 +322,13 @@ impl PythReceiver {
316
322
317
323
match msg {
318
324
Message :: PriceFeedMessage ( price_feed_message) => {
319
- let price_id_fb : FixedBytes < 32 > = FixedBytes :: from ( price_feed_message. feed_id ) ;
320
- let mut recent_price_info = self . latest_price_info . setter ( price_id_fb) ;
321
-
322
325
let price_info_return = (
323
- recent_price_info . publish_time . get ( ) ,
324
- recent_price_info . expo . get ( ) ,
325
- recent_price_info . price . get ( ) ,
326
- recent_price_info . conf . get ( ) ,
327
- recent_price_info . ema_price . get ( ) ,
328
- recent_price_info . ema_conf . get ( ) ,
326
+ U64 :: from ( price_feed_message . publish_time ) ,
327
+ I32 :: from_be_bytes ( price_feed_message . exponent . to_be_bytes ( ) ) ,
328
+ I64 :: from_be_bytes ( price_feed_message . price . to_be_bytes ( ) ) ,
329
+ U64 :: from ( price_feed_message . conf ) ,
330
+ I64 :: from_be_bytes ( price_feed_message . ema_price . to_be_bytes ( ) ) ,
331
+ U64 :: from ( price_feed_message . ema_conf ) ,
329
332
) ;
330
333
331
334
price_feeds. insert ( price_feed_message. feed_id , price_info_return) ;
0 commit comments