@@ -488,6 +488,18 @@ func (p *BimodalEstimator) probabilityFormula(capacityMsat, successAmountMsat,
488
488
return 0.0 , nil
489
489
}
490
490
491
+ // The next statement is a safety check against an illogical condition.
492
+ // We discard the knowledge for the channel in that case since we have
493
+ // inconsistent data.
494
+ if failAmount <= successAmount {
495
+ log .Warnf ("Fail amount (%s) is smaller than or equal to the " +
496
+ "success amount (%s) for capacity (%s)" ,
497
+ failAmountMsat , successAmountMsat , capacityMsat )
498
+
499
+ successAmount = 0
500
+ failAmount = capacity
501
+ }
502
+
491
503
// Mission control may have some outdated values, we correct them here.
492
504
// TODO(bitromortac): there may be better decisions to make in these
493
505
// cases, e.g., resetting failAmount=cap and successAmount=0.
@@ -508,18 +520,6 @@ func (p *BimodalEstimator) probabilityFormula(capacityMsat, successAmountMsat,
508
520
successAmount = capacity
509
521
}
510
522
511
- // The next statement is a safety check against an illogical condition,
512
- // otherwise the renormalization integral would become zero. This may
513
- // happen if a large channel gets closed and smaller ones remain, but
514
- // it should recover with the time decay.
515
- if failAmount <= successAmount {
516
- log .Tracef ("fail amount (%v) is smaller than or equal the " +
517
- "success amount (%v) for capacity (%v)" ,
518
- failAmountMsat , successAmountMsat , capacityMsat )
519
-
520
- return 0.0 , nil
521
- }
522
-
523
523
// We cannot send more than the fail amount.
524
524
if amount >= failAmount {
525
525
return 0.0 , nil
0 commit comments