Skip to content

Commit 289e8ee

Browse files
committed
1 parent 28d41d9 commit 289e8ee

File tree

1 file changed

+6
-3
lines changed
  • programs/portal/src/instructions

1 file changed

+6
-3
lines changed

programs/portal/src/instructions/admin.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,14 @@ pub fn deregister_transceiver(ctx: Context<DeregisterTransceiver>) -> Result<()>
524524
.enabled_transceivers
525525
.set(ctx.accounts.registered_transceiver.id, false)?;
526526

527-
// decrement threshold if too high
528527
let num_enabled_transceivers = ctx.accounts.config.enabled_transceivers.len();
528+
// at least one transceiver should be enabled
529+
if num_enabled_transceivers == 0 {
530+
return Err(NTTError::ZeroThreshold.into());
531+
}
532+
// decrement threshold if too high
529533
if num_enabled_transceivers < ctx.accounts.config.threshold {
530-
// threshold should be at least 1
531-
ctx.accounts.config.threshold = num_enabled_transceivers.max(1);
534+
ctx.accounts.config.threshold = num_enabled_transceivers;
532535
}
533536
Ok(())
534537
}

0 commit comments

Comments
 (0)