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

Function gossmap_local_updatechan

common/gossmap.c:832–876  ·  view source on GitHub ↗

Insert a local-only channel_update. */

Source from the content-addressed store, hash-verified

830
831/* Insert a local-only channel_update. */
832bool gossmap_local_updatechan(struct gossmap_localmods *localmods,
833 const struct short_channel_id *scid,
834 struct amount_msat htlc_min,
835 struct amount_msat htlc_max,
836 u32 base_fee,
837 u32 proportional_fee,
838 u16 delay,
839 bool enabled,
840 int dir)
841{
842 struct localmod *mod;
843
844 mod = find_localmod(localmods, scid);
845 if (!mod) {
846 /* Create new reference to (presumably) existing channel. */
847 size_t nmods = tal_count(localmods->mods);
848
849 tal_resize(&localmods->mods, nmods + 1);
850 mod = &localmods->mods[nmods];
851 mod->scid = *scid;
852 mod->updates_set[0] = mod->updates_set[1] = false;
853 mod->local_off = 0xFFFFFFFF;
854 }
855
856 assert(dir == 0 || dir == 1);
857 mod->updates_set[dir] = true;
858 mod->hc[dir].enabled = enabled;
859 /* node_idx needs to be set once we're in the gossmap. */
860 mod->hc[dir].htlc_min
861 = u64_to_fp16(htlc_min.millisatoshis, /* Raw: to fp16 */
862 false);
863 mod->hc[dir].htlc_max
864 = u64_to_fp16(htlc_max.millisatoshis, /* Raw: to fp16 */
865 true);
866 mod->hc[dir].base_fee = base_fee;
867 mod->hc[dir].proportional_fee = proportional_fee;
868 mod->hc[dir].delay = delay;
869
870 /* Check they fit */
871 if (mod->hc[dir].base_fee != base_fee
872 || mod->hc[dir].proportional_fee != proportional_fee
873 || mod->hc[dir].delay != delay)
874 return false;
875 return true;
876}
877
878/* Apply localmods to this map */
879void gossmap_apply_localmods(struct gossmap *map,

Callers 1

mainFunction · 0.85

Calls 2

find_localmodFunction · 0.85
u64_to_fp16Function · 0.85

Tested by 1

mainFunction · 0.68