@@ -500,24 +500,36 @@ func (p *BimodalEstimator) probabilityFormula(capacityMsat, successAmountMsat,
500
500
failAmount = capacity
501
501
}
502
502
503
- // Mission control may have some outdated values, we correct them here.
504
- // TODO(bitromortac): there may be better decisions to make in these
505
- // cases, e.g., resetting failAmount=cap and successAmount=0.
506
-
507
- // failAmount should be capacity at max.
508
- if failAmount > capacity {
509
- log .Debugf ("Correcting failAmount %v to capacity %v" ,
510
- failAmount , capacity )
511
-
503
+ // Mission control may have some outdated values with regard to the
504
+ // current channel capacity between a node pair. This can happen in case
505
+ // a large parallel channel was closed or if a channel was downscaled
506
+ // and can lead to success and/or failure amounts to be out of the range
507
+ // [0, capacity]. We assume that the liquidity situation of the channel
508
+ // is similar as before due to flow bias.
509
+
510
+ // In case we have a large success we need to correct it to be in the
511
+ // valid range. We set the success amount close to the capacity, because
512
+ // we assume to still be able to send. Any possible failure (that must
513
+ // in this case be larger than the capacity) is corrected as well.
514
+ if successAmount >= capacity {
515
+ log .Debugf ("Correcting success amount %s and failure amount " +
516
+ "%s to capacity %s" , successAmountMsat ,
517
+ failAmount , capacityMsat )
518
+
519
+ // We choose the success amount to be one less than the
520
+ // capacity, to both fit success and failure amounts into the
521
+ // capacity range in a consistent manner.
522
+ successAmount = capacity - 1
512
523
failAmount = capacity
513
524
}
514
525
515
- // successAmount should be capacity at max.
516
- if successAmount > capacity {
517
- log .Debugf ("Correcting successAmount %v to capacity %v" ,
518
- successAmount , capacity )
526
+ // Having no or only a small success, but a large failure only needs
527
+ // adjustment of the failure amount.
528
+ if failAmount > capacity {
529
+ log .Debugf ("Correcting failure amount %s to capacity %s" ,
530
+ failAmountMsat , capacityMsat )
519
531
520
- successAmount = capacity
532
+ failAmount = capacity
521
533
}
522
534
523
535
// We cannot send more than the fail amount.
0 commit comments