@@ -2470,11 +2470,12 @@ impl LDNApplication {
2470
2470
let active_allocation = db_application_file. allocation . active ( ) ;
2471
2471
2472
2472
if let Some ( active_allocation) = active_allocation {
2473
- if active_allocation. signers . 0 . is_empty ( ) {
2474
- db_application_file. lifecycle . state = AppState :: ReadyToSign
2473
+ // If there is an active allocation, set state based on signers
2474
+ db_application_file. lifecycle . state = if active_allocation. signers . 0 . is_empty ( ) {
2475
+ AppState :: ReadyToSign
2475
2476
} else {
2476
- db_application_file . lifecycle . state = AppState :: StartSignDatacap
2477
- }
2477
+ AppState :: StartSignDatacap
2478
+ } ;
2478
2479
} else if !db_application_file. lifecycle . is_active {
2479
2480
// If application is not active, we need to move it back to granted state and set last verifier and last active request
2480
2481
let last_active_request = Self :: get_last_active_request ( & db_application_file) . ok_or (
@@ -2484,16 +2485,22 @@ impl LDNApplication {
2484
2485
. ok_or ( LDNError :: Load ( "Failed to get last verifier" . to_string ( ) ) ) ?;
2485
2486
db_application_file = db_application_file
2486
2487
. move_back_to_granted_state ( & last_verifier, & last_active_request) ;
2487
- } else if let ( Some ( active_request) , Some ( sps_change_requests) ) = (
2488
- db_application_file. lifecycle . active_request . as_ref ( ) ,
2489
- db_application_file. allowed_sps . as_ref ( ) ,
2490
- ) {
2491
- if sps_change_requests
2492
- . get_active_change_request ( active_request)
2493
- . is_some ( )
2494
- {
2495
- db_application_file. lifecycle . state = AppState :: ChangingSP ;
2496
- }
2488
+ } else if db_application_file
2489
+ . lifecycle
2490
+ . active_request
2491
+ . as_ref ( )
2492
+ . and_then ( |active_request| {
2493
+ db_application_file
2494
+ . allowed_sps
2495
+ . as_ref ( )
2496
+ . and_then ( |sps_change_requests| {
2497
+ sps_change_requests. get_active_change_request ( active_request)
2498
+ } )
2499
+ } )
2500
+ . is_some ( )
2501
+ {
2502
+ // If there is an active SPS change request, set state to ChangingSP
2503
+ db_application_file. lifecycle . state = AppState :: ChangingSP ;
2497
2504
} else {
2498
2505
db_application_file. lifecycle . state = AppState :: Granted ;
2499
2506
}
0 commit comments