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

Function gossmap_local_updatechan

common/gossmap.c:1135–1204  ·  view source on GitHub ↗

Insert a local-only channel_update: false if can't represent. */

Source from the content-addressed store, hash-verified

1133
1134/* Insert a local-only channel_update: false if can't represent. */
1135bool gossmap_local_updatechan(struct gossmap_localmods *localmods,
1136 const struct short_channel_id_dir *scidd,
1137 const bool *enabled,
1138 const struct amount_msat *htlc_min,
1139 const struct amount_msat *htlc_max,
1140 const struct amount_msat *base_fee,
1141 const u32 *proportional_fee,
1142 const u16 *delay)
1143{
1144 struct localmod *mod;
1145 struct localmod_changes *lc;
1146 struct half_chan test;
1147
1148 /* Check fit before making any changes. */
1149 if (base_fee) {
1150 test.base_fee = base_fee->millisatoshis /* Raw: localmod */;
1151 if (!amount_msat_eq(amount_msat(test.base_fee), *base_fee))
1152 return false;
1153 }
1154 if (proportional_fee) {
1155 test.proportional_fee = *proportional_fee;
1156 if (test.proportional_fee != *proportional_fee)
1157 return false;
1158 }
1159 if (delay) {
1160 test.delay = *delay;
1161 if (test.delay != *delay)
1162 return false;
1163 }
1164
1165 mod = find_localmod(localmods, scidd->scid);
1166 if (!mod) {
1167 /* Create new reference to (presumably) existing channel. */
1168 size_t nmods = tal_count(localmods->mods);
1169
1170 tal_resize(&localmods->mods, nmods + 1);
1171 mod = &localmods->mods[nmods];
1172 mod->scid = scidd->scid;
1173 memset(&mod->changes, 0, sizeof(mod->changes));
1174 mod->local_off = 0xFFFFFFFFFFFFFFFFULL;
1175 }
1176
1177 lc = &mod->changes[scidd->dir];
1178 if (enabled) {
1179 tal_free(lc->enabled);
1180 lc->enabled = tal_dup(localmods, bool, enabled);
1181 }
1182 if (htlc_min) {
1183 tal_free(lc->htlc_min);
1184 lc->htlc_min = tal_dup(localmods, struct amount_msat, htlc_min);
1185 }
1186 if (htlc_max) {
1187 tal_free(lc->htlc_max);
1188 lc->htlc_max = tal_dup(localmods, struct amount_msat, htlc_max);
1189 }
1190 if (base_fee) {
1191 u32 base_as_u32 = base_fee->millisatoshis; /* Raw: localmod */
1192 tal_free(lc->base_fee);

Callers 9

gossmod_add_localchanFunction · 0.85
gossmap_local_setchanFunction · 0.85
mainFunction · 0.85
gossmods_from_listpeersFunction · 0.85
layer_add_localmodsFunction · 0.85
do_getroutesFunction · 0.85
gossmod_cbFunction · 0.85
add_hintchanFunction · 0.85

Calls 4

find_localmodFunction · 0.85
tal_freeFunction · 0.85
amount_msat_eqFunction · 0.70
amount_msatClass · 0.70

Tested by 1

mainFunction · 0.68