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

Function uncertainty_update

plugins/renepay/uncertainty.c:74–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74int uncertainty_update(struct uncertainty *uncertainty, struct gossmap *gossmap)
75{
76 /* Each channel in chan_extra_map should be either in gossmap or in
77 * local_gossmods. */
78 assert(uncertainty);
79 struct chan_extra_map *chan_extra_map = uncertainty->chan_extra_map;
80 assert(chan_extra_map);
81 struct chan_extra **del_list = tal_arr(NULL, struct chan_extra*, 0);
82 struct chan_extra_map_iter it;
83 for (struct chan_extra *ch = chan_extra_map_first(chan_extra_map, &it);
84 ch; ch = chan_extra_map_next(chan_extra_map, &it)) {
85
86 /* If we cannot find that channel in the gossmap, add it to the
87 * delete list. */
88 if (!gossmap_find_chan(gossmap, &ch->scid))
89 tal_arr_expand(&del_list, ch);
90 }
91 for(size_t i=0;i<tal_count(del_list);i++) {
92 chan_extra_map_del(chan_extra_map, del_list[i]);
93 del_list[i] = tal_free(del_list[i]);
94 }
95 del_list = tal_free(del_list);
96
97
98 /* For each channel in the gossmap, create a extra data in
99 * chan_extra_map */
100 int skipped_count = 0;
101 for (struct gossmap_chan *chan = gossmap_first_chan(gossmap); chan;
102 chan = gossmap_next_chan(gossmap, chan)) {
103 struct short_channel_id scid = gossmap_chan_scid(gossmap, chan);
104 struct chan_extra *ce =
105 chan_extra_map_get(chan_extra_map, scid);
106 if (!ce) {
107 struct amount_msat cap_msat;
108
109 cap_msat = gossmap_chan_get_capacity(gossmap, chan);
110 if (!new_chan_extra(chan_extra_map, scid,
111 cap_msat)) {
112 /* If the new chan_extra cannot be created we
113 * skip this channel. */
114 skipped_count++;
115 continue;
116 }
117 }
118 }
119 assert(chan_extra_map_count(chan_extra_map) + skipped_count ==
120 gossmap_num_chans(gossmap));
121 return skipped_count;
122}
123
124struct uncertainty *uncertainty_new(const tal_t *ctx)
125{

Callers 5

initFunction · 0.85
refreshgossmap_cbFunction · 0.85
routehints_doneFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 8

gossmap_find_chanFunction · 0.85
tal_freeFunction · 0.85
gossmap_first_chanFunction · 0.85
gossmap_next_chanFunction · 0.85
gossmap_chan_scidFunction · 0.85
new_chan_extraFunction · 0.85
gossmap_num_chansFunction · 0.85

Tested by 2

mainFunction · 0.68
mainFunction · 0.68