Add code comment to amount calculation
Its not immediately obvious that x - y cannot overflow. Add a code comment to explain it.
This commit is contained in:
parent
8cf1dc39b5
commit
56516757ad
|
@ -784,6 +784,8 @@ pub fn effective_value(
|
||||||
let weight = input_weight_prediction.total_weight();
|
let weight = input_weight_prediction.total_weight();
|
||||||
let fee = fee_rate.to_fee(weight);
|
let fee = fee_rate.to_fee(weight);
|
||||||
|
|
||||||
|
// Cannot overflow because after conversion to signed Amount::MIN - Amount::MAX
|
||||||
|
// still fits in SignedAmount::MAX (0 - MAX = -MAX).
|
||||||
(value.to_signed() - fee.to_signed()).expect("cannot overflow")
|
(value.to_signed() - fee.to_signed()).expect("cannot overflow")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue