@@ -173,7 +173,7 @@ impl QueueStatusType {
173173 fn consume_index ( & mut self , removed_index : QueueIndex ) {
174174 if removed_index != self . smallest_index {
175175 self . freed_indices . push ( removed_index. reverse ( ) ) ;
176- return
176+ return ;
177177 }
178178 let mut index = self . smallest_index . 0 . overflowing_add ( 1 ) . 0 ;
179179 // Even more to advance?
@@ -368,10 +368,10 @@ pub mod pallet {
368368 #[ pallet:: event]
369369 #[ pallet:: generate_deposit( pub ( super ) fn deposit_event) ]
370370 pub enum Event < T : Config > {
371- /// An order was placed at some spot price amount.
372- OnDemandOrderPlaced { para_id : ParaId , spot_price : BalanceOf < T > } ,
373- /// The value of the spot traffic multiplier changed.
374- SpotTrafficSet { traffic : FixedU128 } ,
371+ /// An order was placed at some spot price amount by orderer ordered_by
372+ OnDemandOrderPlaced { para_id : ParaId , spot_price : BalanceOf < T > , ordered_by : T :: AccountId } ,
373+ /// The value of the spot price has likely changed
374+ SpotPriceSet { spot_price : BalanceOf < T > } ,
375375 }
376376
377377 #[ pallet:: error]
@@ -410,12 +410,11 @@ pub mod pallet {
410410 ///
411411 /// Errors:
412412 /// - `InsufficientBalance`: from the Currency implementation
413- /// - `InvalidParaId`
414413 /// - `QueueFull`
415414 /// - `SpotPriceHigherThanMaxAmount`
416415 ///
417416 /// Events:
418- /// - `SpotOrderPlaced `
417+ /// - `OnDemandOrderPlaced `
419418 #[ pallet:: call_index( 0 ) ]
420419 #[ pallet:: weight( <T as Config >:: WeightInfo :: place_order_allow_death( QueueStatus :: <T >:: get( ) . size( ) ) ) ]
421420 pub fn place_order_allow_death (
@@ -437,12 +436,11 @@ pub mod pallet {
437436 ///
438437 /// Errors:
439438 /// - `InsufficientBalance`: from the Currency implementation
440- /// - `InvalidParaId`
441439 /// - `QueueFull`
442440 /// - `SpotPriceHigherThanMaxAmount`
443441 ///
444442 /// Events:
445- /// - `SpotOrderPlaced `
443+ /// - `OnDemandOrderPlaced `
446444 #[ pallet:: call_index( 1 ) ]
447445 #[ pallet:: weight( <T as Config >:: WeightInfo :: place_order_keep_alive( QueueStatus :: <T >:: get( ) . size( ) ) ) ]
448446 pub fn place_order_keep_alive (
@@ -539,12 +537,11 @@ where
539537 ///
540538 /// Errors:
541539 /// - `InsufficientBalance`: from the Currency implementation
542- /// - `InvalidParaId`
543540 /// - `QueueFull`
544541 /// - `SpotPriceHigherThanMaxAmount`
545542 ///
546543 /// Events:
547- /// - `SpotOrderPlaced `
544+ /// - `OnDemandOrderPlaced `
548545 fn do_place_order (
549546 sender : <T as frame_system:: Config >:: AccountId ,
550547 max_amount : BalanceOf < T > ,
@@ -578,6 +575,12 @@ where
578575 Error :: <T >:: QueueFull
579576 ) ;
580577 Pallet :: < T > :: add_on_demand_order ( queue_status, para_id, QueuePushDirection :: Back ) ;
578+ Pallet :: < T > :: deposit_event ( Event :: < T > :: OnDemandOrderPlaced {
579+ para_id,
580+ spot_price,
581+ ordered_by : sender,
582+ } ) ;
583+
581584 Ok ( ( ) )
582585 } )
583586 }
@@ -599,7 +602,14 @@ where
599602 // Only update storage on change
600603 if new_traffic != old_traffic {
601604 queue_status. traffic = new_traffic;
602- Pallet :: < T > :: deposit_event ( Event :: < T > :: SpotTrafficSet { traffic : new_traffic } ) ;
605+
606+ // calculate the new spot price
607+ let spot_price: BalanceOf < T > = new_traffic. saturating_mul_int (
608+ config. scheduler_params . on_demand_base_fee . saturated_into :: < BalanceOf < T > > ( ) ,
609+ ) ;
610+
611+ // emit the event for updated new price
612+ Pallet :: < T > :: deposit_event ( Event :: < T > :: SpotPriceSet { spot_price } ) ;
603613 }
604614 } ,
605615 Err ( err) => {
@@ -721,7 +731,7 @@ where
721731 "Decreased affinity for a para that has not been served on a core?"
722732 ) ;
723733 if affinity != Some ( 0 ) {
724- return
734+ return ;
725735 }
726736 // No affinity more for entries on this core, free any entries:
727737 //
@@ -754,7 +764,7 @@ where
754764 } else {
755765 * maybe_affinity = None ;
756766 }
757- return Some ( new_count)
767+ return Some ( new_count) ;
758768 } else {
759769 None
760770 }
0 commit comments