MCPcopy Create free account
hub / github.com/ElementsProject/lightning / chan_extra_adjust_half

Function chan_extra_adjust_half

plugins/renepay/chan_extra.c:239–256  ·  view source on GitHub ↗

This helper function preserves the uncertainty network invariant after the * knowledge is updated. It assumes that the (channel,!dir) knowledge is * correct. */

Source from the content-addressed store, hash-verified

237 * knowledge is updated. It assumes that the (channel,!dir) knowledge is
238 * correct. */
239static 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.*/
259static enum renepay_errorcode

Callers 5

chan_extra_can_send_Function · 0.85
chan_extra_cannot_sendFunction · 0.85
chan_extra_sent_successFunction · 0.85
chan_extra_relaxFunction · 0.85

Calls 1

amount_msat_subFunction · 0.85

Tested by

no test coverage detected