@@ -245,11 +245,12 @@ pub mod pallet {
245245 #[ pallet:: event]
246246 #[ pallet:: generate_deposit( pub ( super ) fn deposit_event) ]
247247 pub enum Event < T : Config > {
248+ /// Beacon Configuration has changed.
248249 BeaconConfigChanged ,
249250 /// Successfully set a new pulse(s).
250- NewPulse {
251- rounds : Vec < RoundNumber > ,
252- } ,
251+ NewPulse { rounds : Vec < RoundNumber > } ,
252+ /// Oldest Stored Round has been set.
253+ SetOldestStoredRound ( u64 ) ,
253254 }
254255
255256 #[ pallet:: error]
@@ -277,11 +278,12 @@ pub mod pallet {
277278 }
278279 }
279280 fn on_runtime_upgrade ( ) -> frame_support:: weights:: Weight {
280- let mut weight = frame_support:: weights:: Weight :: from_parts ( 0 , 0 ) ;
281+ /*let weight = */
282+ frame_support:: weights:: Weight :: from_parts ( 0 , 0 ) /*;*/
281283
282- weight = weight. saturating_add ( migrations:: migrate_set_oldest_round :: < T > ( ) ) ;
284+ // weight = weight.saturating_add(migrations::migrate_set_oldest_round::<T>());
283285
284- weight
286+ // weight
285287 }
286288 }
287289
@@ -420,6 +422,18 @@ pub mod pallet {
420422 Self :: deposit_event ( Event :: BeaconConfigChanged { } ) ;
421423 Ok ( ( ) )
422424 }
425+
426+ /// allows the root user to set the oldest stored round
427+ #[ pallet:: call_index( 2 ) ]
428+ #[ pallet:: weight( Weight :: from_parts( 5_630_000 , 0 )
429+ . saturating_add( T :: DbWeight :: get( ) . reads( 0_u64 ) )
430+ . saturating_add( T :: DbWeight :: get( ) . writes( 1_u64 ) ) ) ]
431+ pub fn set_oldest_stored_round ( origin : OriginFor < T > , oldest_round : u64 ) -> DispatchResult {
432+ ensure_root ( origin) ?;
433+ OldestStoredRound :: < T > :: put ( oldest_round) ;
434+ Self :: deposit_event ( Event :: SetOldestStoredRound ( oldest_round) ) ;
435+ Ok ( ( ) )
436+ }
423437 }
424438}
425439
0 commit comments