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

Function free_htlcs

lightningd/peer_htlcs.c:2818–2849  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2816
2817/* If channel is NULL, free them all (for shutdown) */
2818void free_htlcs(struct lightningd *ld, const struct channel *channel)
2819{
2820 struct htlc_out_map_iter outi;
2821 struct htlc_out *hout;
2822 struct htlc_in_map_iter ini;
2823 struct htlc_in *hin;
2824 bool deleted;
2825
2826 /* FIXME: Implement check_htlcs to ensure no dangling hout->in ptrs! */
2827
2828 do {
2829 deleted = false;
2830 for (hout = htlc_out_map_first(ld->htlcs_out, &outi);
2831 hout;
2832 hout = htlc_out_map_next(ld->htlcs_out, &outi)) {
2833 if (channel && hout->key.channel != channel)
2834 continue;
2835 tal_free(hout);
2836 deleted = true;
2837 }
2838
2839 for (hin = htlc_in_map_first(ld->htlcs_in, &ini);
2840 hin;
2841 hin = htlc_in_map_next(ld->htlcs_in, &ini)) {
2842 if (channel && hin->key.channel != channel)
2843 continue;
2844 tal_free(hin);
2845 deleted = true;
2846 }
2847 /* Can skip over elements due to iterating while deleting. */
2848 } while (deleted);
2849}
2850
2851/* BOLT #2:
2852 *

Callers 3

drop_to_chainFunction · 0.70
free_all_channelsFunction · 0.70

Calls 1

tal_freeFunction · 0.85

Tested by

no test coverage detected