@@ -191,7 +191,7 @@ impl PythReceiver {
191
191
min_publish_time : u64 ,
192
192
max_publish_time : u64 ,
193
193
_unique : bool ,
194
- ) -> Result < ( ) , PythReceiverError > {
194
+ ) -> Result < Vec < ( [ u8 ; 32 ] , PriceInfoReturn ) > , PythReceiverError > {
195
195
let price_pairs = self . parse_price_feed_updates_internal (
196
196
update_data,
197
197
min_publish_time,
@@ -201,7 +201,7 @@ impl PythReceiver {
201
201
true , // store_updates_if_fresh
202
202
) ?;
203
203
204
- for ( price_id, price_return) in price_pairs {
204
+ for ( price_id, price_return) in price_pairs. clone ( ) {
205
205
let price_id_fb: FixedBytes < 32 > = FixedBytes :: from ( price_id) ;
206
206
let mut recent_price_info = self . latest_price_info . setter ( price_id_fb) ;
207
207
@@ -217,7 +217,7 @@ impl PythReceiver {
217
217
}
218
218
}
219
219
220
- Ok ( ( ) )
220
+ Ok ( price_pairs )
221
221
}
222
222
223
223
fn get_update_fee ( & self , update_data : Vec < u8 > ) -> Result < U256 , PythReceiverError > {
@@ -266,14 +266,29 @@ impl PythReceiver {
266
266
check_update_data_is_minimal : bool ,
267
267
store_updates_if_fresh : bool ,
268
268
) -> Result < Vec < PriceInfoReturn > , PythReceiverError > {
269
- let price_pairs = self . parse_price_feed_updates_internal (
270
- update_data,
271
- min_allowed_publish_time,
272
- max_allowed_publish_time,
273
- check_uniqueness,
274
- check_update_data_is_minimal,
275
- store_updates_if_fresh,
276
- ) ?;
269
+ let price_pairs;
270
+ if store_updates_if_fresh {
271
+ price_pairs = self . update_price_feeds_internal (
272
+ update_data,
273
+ price_ids. clone ( ) ,
274
+ min_allowed_publish_time,
275
+ max_allowed_publish_time,
276
+ check_uniqueness,
277
+ ) ?;
278
+ } else {
279
+ price_pairs = self . parse_price_feed_updates_internal (
280
+ update_data,
281
+ min_allowed_publish_time,
282
+ max_allowed_publish_time,
283
+ check_uniqueness,
284
+ check_update_data_is_minimal,
285
+ store_updates_if_fresh,
286
+ ) ?;
287
+ }
288
+
289
+ if check_update_data_is_minimal && price_ids. len ( ) != price_pairs. len ( ) {
290
+ return Err ( PythReceiverError :: InvalidUpdateData ) ;
291
+ }
277
292
278
293
let price_map: BTreeMap < [ u8 ; 32 ] , PriceInfoReturn > = price_pairs. into_iter ( ) . collect ( ) ;
279
294
@@ -283,14 +298,7 @@ impl PythReceiver {
283
298
if let Some ( price_info) = price_map. get ( & price_id) {
284
299
result. push ( * price_info) ;
285
300
} else {
286
- result. push ( (
287
- U64 :: from ( 0 ) ,
288
- I32 :: from_be_bytes ( [ 0 , 0 , 0 , 0 ] ) ,
289
- I64 :: from_be_bytes ( [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ) ,
290
- U64 :: from ( 0 ) ,
291
- I64 :: from_be_bytes ( [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ) ,
292
- U64 :: from ( 0 ) ,
293
- ) ) ;
301
+ return Err ( PythReceiverError :: PriceFeedNotFoundWithinRange ) ;
294
302
}
295
303
}
296
304
0 commit comments