@@ -97,6 +97,7 @@ pub fn update_accumulator(bank: &Bank) {
97
97
} ;
98
98
}
99
99
100
+ // TODO: No longer a slot or feature flag, based on price account flag.
100
101
if ( * ACCUMULATOR_V2_SLOT ) . map_or ( false , |v2_slot| bank. slot ( ) >= v2_slot) {
101
102
if let Err ( e) = update_v2 ( bank) {
102
103
error ! ( "Error updating accumulator: {:?}" , e) ;
@@ -398,14 +399,28 @@ pub fn update_v2(bank: &Bank) -> std::result::Result<(), AccumulatorUpdateErrorV
398
399
. get_program_accounts ( & oracle_pubkey, & ScanConfig :: new ( true ) )
399
400
. map_err ( AccumulatorUpdateErrorV2 :: GetProgramAccounts ) ?;
400
401
401
- // 3. Filter for Price Accounts
402
- let accounts = accounts. iter ( ) . filter ( |( _, account) | true ) ;
402
+ // 3. Call Aggregation on Price Accounts.
403
+ for ( pubkey, mut account) in accounts {
404
+ let mut price_account_data = account. data ( ) . to_owned ( ) ;
405
+
406
+ // Perform Accumulation
407
+ match pyth_oracle:: validator:: aggregate_price (
408
+ bank. slot ( ) ,
409
+ bank. clock ( ) . unix_timestamp ,
410
+ & mut price_account_data,
411
+ ) {
412
+ Ok ( success) => {
413
+ if success {
414
+ account. set_data ( price_account_data) ;
415
+ bank. store_account_and_update_capitalization ( & pubkey, & account) ;
416
+ }
417
+ }
418
+ Err ( err) => trace ! ( "Aggregation: failed to update_price_cumulative, {:?}" , err) ,
419
+ }
420
+ }
403
421
404
- // 4. Pass the PriceAccounts to the Oracle Code
405
- // - Change Oracle to not run update code.
406
- // - Change Oracle to have the aggregation code itself as a pure function.
407
- // - Call aggregation with PriceAccount as input.
408
422
// 5. Merkleize the results.
423
+
409
424
// 6. Create Wormhole Message Account
410
425
411
426
Ok ( ( ) )
0 commit comments