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