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

Function gossmap_apply_localmods

common/gossmap.c:1225–1334  ·  view source on GitHub ↗

Apply localmods to this map */

Source from the content-addressed store, hash-verified

1223
1224/* Apply localmods to this map */
1225void gossmap_apply_localmods(struct gossmap *map,
1226 struct gossmap_localmods *localmods)
1227{
1228 size_t n = tal_count(localmods->mods);
1229
1230 assert(!map->local_announces);
1231 map->local_announces = localmods->local_announces;
1232 map->local_updates = tal_arr(map, u8, 0);
1233
1234 for (size_t i = 0; i < n; i++) {
1235 struct localmod *mod = &localmods->mods[i];
1236 struct gossmap_chan *chan;
1237
1238 /* Find gossmap entry which this applies to. */
1239 chan = gossmap_find_chan(map, &mod->scid);
1240 /* If it doesn't exist, are we supposed to create a local one? */
1241 if (!chan) {
1242 if (!localmod_is_local_chan(mod))
1243 continue;
1244
1245 /* Create new channel, pointing into local. */
1246 chan = add_channel(map, map->map_size + mod->local_off, 0, NULL);
1247 }
1248
1249 /* Save old, update any fields they wanted to change */
1250 for (size_t h = 0; h < 2; h++) {
1251 const struct localmod_changes *c = &mod->changes[h];
1252 /* Default values all zero, disabled */
1253 u32 timestamp = 0;
1254 u8 message_flags = ROUTING_OPT_HTLC_MAX_MSAT, channel_flags = h | ROUTING_FLAGS_DISABLED;
1255 u16 cltv_expiry_delta = 0;
1256 u32 fee_base_msat = 0, fee_proportional_millionths = 0;
1257 struct amount_msat htlc_minimum_msat = AMOUNT_MSAT(0),
1258 htlc_maximum_msat = AMOUNT_MSAT(0);
1259 const u8 *cupdatemsg;
1260 secp256k1_ecdsa_signature fake_signature;
1261 struct bitcoin_blkid fake_blkid;
1262 struct short_channel_id_dir scidd;
1263 u64 off;
1264 bool any_set = false;
1265
1266 /* Save existing versions */
1267 mod->orig[h] = chan->half[h];
1268 mod->orig_cupdate_off[h] = chan->cupdate_off[h];
1269
1270 /* If we have a previous one, base it on that! */
1271 if (gossmap_chan_set(chan, h)) {
1272 gossmap_chan_get_update_details(map, chan, h,
1273 &timestamp,
1274 &message_flags,
1275 &channel_flags,
1276 &cltv_expiry_delta,
1277 &fee_base_msat,
1278 &fee_proportional_millionths,
1279 &htlc_minimum_msat,
1280 &htlc_maximum_msat);
1281 any_set = true;
1282 }

Callers 15

mainFunction · 0.85
mainFunction · 0.85
path_to_nodeFunction · 0.85
get_gossmapFunction · 0.85
source_free_layerFunction · 0.85
do_getroutesFunction · 0.85
refreshgossmap_cbFunction · 0.85
routehints_doneFunction · 0.85
compute_routes_cbFunction · 0.85

Calls 9

gossmap_find_chanFunction · 0.85
localmod_is_local_chanFunction · 0.85
add_channelFunction · 0.85
gossmap_chan_setFunction · 0.85
insert_local_spaceFunction · 0.85
tal_bytelenFunction · 0.85
fill_from_updateFunction · 0.85
short_channel_id_eqFunction · 0.85

Tested by 4

mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68