@@ -392,17 +392,16 @@ pub fn on_term_close(
392
392
let current_term = metadata. current_term_id ( ) ;
393
393
ctrace ! ( ENGINE , "on_term_close. current_term: {}" , current_term) ;
394
394
395
+ let metadata = metadata. params ( ) . expect (
396
+ "Term close events can be called after the ChangeParams called, \
397
+ so the metadata always has CommonParams",
398
+ ) ;
399
+ let custody_period = metadata. custody_period ( ) ;
400
+ let release_period = metadata. release_period ( ) ;
401
+
395
402
let ( nomination_expiration, custody_until, kick_at) = {
396
- let metadata = metadata. params ( ) . expect (
397
- "Term close events can be called after the ChangeParams called, \
398
- so the metadata always has CommonParams",
399
- ) ;
400
403
let nomination_expiration = metadata. nomination_expiration ( ) ;
401
404
assert_ne ! ( 0 , nomination_expiration) ;
402
- let custody_period = metadata. custody_period ( ) ;
403
- assert_ne ! ( 0 , custody_period) ;
404
- let release_period = metadata. release_period ( ) ;
405
- assert_ne ! ( 0 , release_period) ;
406
405
( nomination_expiration, current_term + custody_period, current_term + release_period)
407
406
} ;
408
407
@@ -412,7 +411,10 @@ pub fn on_term_close(
412
411
let reverted: Vec < _ > = expired. into_iter ( ) . chain ( released) . collect ( ) ;
413
412
revert_delegations ( state, & reverted) ?;
414
413
415
- jail ( state, inactive_validators, custody_until, kick_at) ?;
414
+ let jail_enabled = custody_period != 0 || release_period != 0 ;
415
+ if jail_enabled {
416
+ jail ( state, inactive_validators, custody_until, kick_at) ?;
417
+ }
416
418
417
419
let validators = Validators :: elect ( state) ?;
418
420
validators. save_to_state ( state) ?;
0 commit comments