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

Function free_htlcs

lightningd/peer_htlcs.c:2526–2557  ·  view source on GitHub ↗

If channel is NULL, free them all (for shutdown) */

Source from the content-addressed store, hash-verified

2524
2525/* If channel is NULL, free them all (for shutdown) */
2526void free_htlcs(struct lightningd *ld, const struct channel *channel)
2527{
2528 struct htlc_out_map_iter outi;
2529 struct htlc_out *hout;
2530 struct htlc_in_map_iter ini;
2531 struct htlc_in *hin;
2532 bool deleted;
2533
2534 /* FIXME: Implement check_htlcs to ensure no dangling hout->in ptrs! */
2535
2536 do {
2537 deleted = false;
2538 for (hout = htlc_out_map_first(&ld->htlcs_out, &outi);
2539 hout;
2540 hout = htlc_out_map_next(&ld->htlcs_out, &outi)) {
2541 if (channel && hout->key.channel != channel)
2542 continue;
2543 tal_free(hout);
2544 deleted = true;
2545 }
2546
2547 for (hin = htlc_in_map_first(&ld->htlcs_in, &ini);
2548 hin;
2549 hin = htlc_in_map_next(&ld->htlcs_in, &ini)) {
2550 if (channel && hin->key.channel != channel)
2551 continue;
2552 tal_free(hin);
2553 deleted = true;
2554 }
2555 /* Can skip over elements due to iterating while deleting. */
2556 } while (deleted);
2557}
2558
2559/* BOLT #2:
2560 *

Callers 2

free_all_channelsFunction · 0.70

Calls 1

tal_freeFunction · 0.85

Tested by

no test coverage detected