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

Function new_chan_extra

plugins/renepay/chan_extra.c:88–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88struct chan_extra *new_chan_extra(struct chan_extra_map *chan_extra_map,
89 const struct short_channel_id scid,
90 struct amount_msat capacity)
91{
92 assert(chan_extra_map);
93 struct chan_extra *ce = tal(chan_extra_map, struct chan_extra);
94 if (!ce)
95 return ce;
96
97 ce->scid = scid;
98 ce->capacity = capacity;
99 for (size_t i = 0; i <= 1; i++) {
100 ce->half[i].num_htlcs = 0;
101 ce->half[i].htlc_total = AMOUNT_MSAT(0);
102 ce->half[i].known_min = AMOUNT_MSAT(0);
103 ce->half[i].known_max = capacity;
104 }
105 if (!chan_extra_map_add(chan_extra_map, ce)) {
106 return tal_free(ce);
107 }
108
109 /* Remove self from map when done */
110 // TODO(eduardo):
111 // Is this desctructor really necessary? the chan_extra will deallocated
112 // when the chan_extra_map is freed. Anyways valgrind complains that the
113 // hash table is removing the element with a freed pointer.
114 // tal_add_destructor2(ce, destroy_chan_extra, chan_extra_map);
115 return ce;
116}
117
118/* Based on the knowledge that we have and HTLCs, returns the greatest
119 * amount that we can send through this channel. */

Callers 4

uncertainty_updateFunction · 0.85
uncertainty_add_channelFunction · 0.85
mainFunction · 0.85

Calls 1

tal_freeFunction · 0.85

Tested by 1

mainFunction · 0.68