add a function to modify localmods #7389
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: