Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a function to modify localmods #7389

Conversation

Lagrang3
Copy link
Collaborator

@Lagrang3 Lagrang3 commented Jun 12, 2024

Function gossmap_local_updatechan can be used to add changes to the gossmap that will apply only locally/temporarily. The function takes as arguments all fields inside a half_chan.
The problem is that there is no API to get the current values inside a gossmap_localmods. Therefore there is no way to update for instance a single field inside one specific localmod without overwritting the other properties.

In this PR I add a new function gossmap_local_updatechan_selected that updates the localmod by changing only selected fields passed as arguments, null values will be ignored. If the localmod does not exist for that scid, it will fetch the original channel values, if the localmod already exists it will fetch those channel values instead, then it will modify the selected fields only.

As a result we can have a localmod API that can stack property modifications on several calls. For instance:

gossmap_local_addchan(...); // create a localmod
gossmap_local_updatechan(...); // update all properties 
gossmap_local_updatechan_selected(..., enabled=false); // make sure enable is false, keep the rest as it is
gossmap_local_updatechan_selected(..., base_fee = 0); // make sure base_fee is 0, keep the rest as it is

Function gossmap_local_updatechan can be used to add changes to the
gossmap that will apply only locally/temporarily. The function takes as
arguments all fields inside a half_chan.
The problem is that there is no API to get the current values inside a
gossmap_localmods. Therefore there is no way to update for instance a
single field inside one specific localmod without overwritting the other
properties.

In this PR I add a new function gossmap_local_updatechan_selected that
updates the localmod by changing only selected fields passed as
arguments, null values will be ignored. If the localmod does not exist
for that scid, it will fetch the original channel values, if the
localmod already exists it will fetch those channel values instead,
then it will modify the selected fields only.

As a result we can have a localmod API that can stack property
modifications on several calls. For instance:

gossmap_local_addchan(...); // create a localmod
gossmap_local_updatechan(...); // update all properties
gossmap_local_updatechan_selected(..., enabled=false); // make sure enable is false, keep the rest as it is
gossmap_local_updatechan_selected(..., base_fee = 0); // make sure base_fee is 0, keep the rest as it is

Changelog-Added: a new function gossmap_local_updatechan_selected to
selectively modify some fields on an already existing or absent
gossmap_localmods.

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
@rustyrussell
Copy link
Contributor

I'm a bit confused? The current values are all available in the struct gossmap_chan for the localmod? This means you can build such an API?

@Lagrang3 Lagrang3 closed this Jul 15, 2024
@Lagrang3 Lagrang3 reopened this Jul 15, 2024
@Lagrang3
Copy link
Collaborator Author

@rustyrussell, anyone can read a gossmap_chan data and produce a localmod with gossmap_local_updatechan, but I don't see how you can add an update to a localmod. There is no public interface to get the values of a localmod.
struct localmod, struct gossmap_localmods and find_localmod are hidden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants