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

Function chan_extra_can_send_

plugins/renepay/chan_extra.c:259–289  ·  view source on GitHub ↗

Update the knowledge that this (channel,direction) can send x msat.*/

Source from the content-addressed store, hash-verified

257
258/* Update the knowledge that this (channel,direction) can send x msat.*/
259static enum renepay_errorcode
260chan_extra_can_send_(struct chan_extra *ce, int dir, struct amount_msat x)
261{
262 assert(ce);
263 assert(dir == 0 || dir == 1);
264 enum renepay_errorcode err;
265
266 if (amount_msat_greater(x, ce->capacity))
267 return RENEPAY_PRECONDITION_ERROR;
268
269 struct amount_msat known_min, known_max;
270
271 // in case we fail, let's remember the original state
272 known_min = ce->half[dir].known_min;
273 known_max = ce->half[dir].known_max;
274
275 ce->half[dir].known_min = amount_msat_max(ce->half[dir].known_min, x);
276 ce->half[dir].known_max = amount_msat_max(ce->half[dir].known_max, x);
277
278 err = chan_extra_adjust_half(ce, !dir);
279 if (err != RENEPAY_NOERROR)
280 goto restore_and_fail;
281
282 return RENEPAY_NOERROR;
283
284restore_and_fail:
285 // we fail, thus restore the original state
286 ce->half[dir].known_min = known_min;
287 ce->half[dir].known_max = known_max;
288 return err;
289}
290
291enum renepay_errorcode
292chan_extra_can_send(struct chan_extra_map *chan_extra_map,

Callers 1

chan_extra_can_sendFunction · 0.85

Calls 3

amount_msat_greaterFunction · 0.85
amount_msat_maxFunction · 0.85
chan_extra_adjust_halfFunction · 0.85

Tested by

no test coverage detected