Skip to content

Commit 4e6aa70

Browse files
committed
Error instead of debug_assert in resource manager
When adding a new channel, return an error instead of debug_assert if the allocated values for the buckets are invalid.
1 parent 1abc722 commit 4e6aa70

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lightning/src/ln/resource_manager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,9 @@ impl Channel {
459459
general_bucket_pct,
460460
congestion_bucket_pct,
461461
);
462-
debug_assert!(alloc.general_slots >= 5, "5 is the minimum we need for general bucket");
463-
debug_assert!(alloc.congestion_slots > 0);
464-
debug_assert!(alloc.protected_slots > 0);
462+
if alloc.general_slots < 5 || alloc.congestion_slots == 0 || alloc.protected_slots == 0 {
463+
return Err(());
464+
}
465465

466466
Ok(Channel {
467467
max_htlc_value_in_flight_msat,

0 commit comments

Comments
 (0)