This helper function preserves the uncertainty network invariant after the * knowledge is updated. It assumes that the (channel,!dir) knowledge is * correct. */
| 237 | * knowledge is updated. It assumes that the (channel,!dir) knowledge is |
| 238 | * correct. */ |
| 239 | static enum renepay_errorcode chan_extra_adjust_half(struct chan_extra *ce, |
| 240 | int dir) |
| 241 | { |
| 242 | assert(ce); |
| 243 | assert(dir == 0 || dir == 1); |
| 244 | |
| 245 | struct amount_msat new_known_max, new_known_min; |
| 246 | |
| 247 | if (!amount_msat_sub(&new_known_max, ce->capacity, |
| 248 | ce->half[!dir].known_min) || |
| 249 | !amount_msat_sub(&new_known_min, ce->capacity, |
| 250 | ce->half[!dir].known_max)) |
| 251 | return RENEPAY_AMOUNT_OVERFLOW; |
| 252 | |
| 253 | ce->half[dir].known_max = new_known_max; |
| 254 | ce->half[dir].known_min = new_known_min; |
| 255 | return RENEPAY_NOERROR; |
| 256 | } |
| 257 | |
| 258 | /* Update the knowledge that this (channel,direction) can send x msat.*/ |
| 259 | static enum renepay_errorcode |
no test coverage detected