@@ -131,9 +131,9 @@ pub fn get_accumulator_keys() -> Vec<(
131
131
accumulator_pubkeys
132
132
}
133
133
134
- pub fn update_v1 (
134
+ pub fn update_v1 < ' a > (
135
135
bank : & Bank ,
136
- v2_messages : Vec < & [ u8 ] > ,
136
+ v2_messages : Vec < & ' a [ u8 ] > ,
137
137
use_message_buffers : bool ,
138
138
) -> std:: result:: Result < ( ) , AccumulatorUpdateErrorV1 > {
139
139
use {
@@ -214,8 +214,8 @@ pub fn update_v1(
214
214
Vec :: new ( )
215
215
} ;
216
216
217
- let mut messages = v1_messages ;
218
- messages. extend ( v2_messages ) ;
217
+ let mut messages = v2_messages ;
218
+ messages. extend ( v1_messages ) ;
219
219
220
220
// We now generate a Proof PDA (Owned by the System Program) to store the resulting Proof
221
221
// Set. The derivation includes the ring buffer index to simulate a ring buffer in order
@@ -384,7 +384,8 @@ pub fn update_v2(bank: &Bank) -> std::result::Result<(), AccumulatorUpdateErrorV
384
384
. get_program_accounts ( & oracle_pubkey, & ScanConfig :: new ( true ) )
385
385
. map_err ( AccumulatorUpdateErrorV1 :: GetProgramAccounts ) ?;
386
386
387
- let mut any_legacy_mode = false ;
387
+ let mut any_v1_aggregations = false ;
388
+ let mut v2_messages = Vec :: new ( ) ;
388
389
389
390
// 3. Call Aggregation on Price Accounts.
390
391
for ( pubkey, mut account) in accounts {
@@ -394,26 +395,31 @@ pub fn update_v2(bank: &Bank) -> std::result::Result<(), AccumulatorUpdateErrorV
394
395
match pyth_oracle:: validator:: aggregate_price (
395
396
bank. slot ( ) ,
396
397
bank. clock ( ) . unix_timestamp ,
398
+ & pubkey. to_bytes ( ) . into ( ) ,
397
399
& mut price_account_data,
398
400
) {
399
- Ok ( ( ) ) => {
400
- account. set_data ( price_account_data) ;
401
- bank. store_account_and_update_capitalization ( & pubkey, & account) ;
401
+ Ok ( outcome) => {
402
+ if outcome. commit {
403
+ account. set_data ( price_account_data) ;
404
+ bank. store_account_and_update_capitalization ( & pubkey, & account) ;
405
+ }
406
+ v2_messages. extend ( outcome. messages ) ;
402
407
}
403
408
Err ( err) => match err {
404
409
AggregationError :: NotPriceFeedAccount => { }
405
- AggregationError :: LegacyAggregationMode => {
406
- any_legacy_mode = true ;
407
- }
408
- AggregationError :: NotTradingStatus => {
409
- trace ! ( "Aggregation: failed to update_price_cumulative, {:?}" , err) ;
410
+ AggregationError :: V1AggregationMode => {
411
+ any_v1_aggregations = true ;
410
412
}
411
413
} ,
412
414
}
413
415
}
414
416
415
417
// TODO: make new messages
416
- update_v1 ( bank, Vec :: new ( ) , any_legacy_mode) ?;
418
+ update_v1 (
419
+ bank,
420
+ v2_messages. iter ( ) . map ( |x| & * * x) . collect ( ) ,
421
+ any_v1_aggregations,
422
+ ) ?;
417
423
418
424
// 5. Merkleize the results.
419
425
0 commit comments