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

Function gossmap_apply_localmods

common/gossmap.c:1220–1329  ·  view source on GitHub ↗

Apply localmods to this map */

Source from the content-addressed store, hash-verified

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

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