Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions plugins/renepay/uncertainty_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,29 @@ void uncertainty_network_update(

if(!gossmap_chan_get_capacity(gossmap,chan,&cap))
{
plugin_err(pay_plugin->plugin,"%s (line %d) unable to fetch channel capacity",
__PRETTY_FUNCTION__,
__LINE__);
/* This can happen transiently if gossipd is
* writing it to the store right now. Set
* it to larger htlc_max */
cap_msat = AMOUNT_MSAT(0);
for (int dir = 0; dir < 2; dir++)
{
struct amount_msat htlc_max;
if (!gossmap_chan_set(chan, dir))
continue;
htlc_max = amount_msat(fp16_to_u64(chan->half[dir].htlc_max));
if (amount_msat_greater(htlc_max, cap_msat))
cap_msat = htlc_max;
}
plugin_log(pay_plugin->plugin, LOG_UNUSUAL,
"Cannot fetch capacity for channel %s: using %s",
fmt_short_channel_id(tmpctx, scid),
fmt_amount_msat(tmpctx, cap_msat));
Comment on lines +173 to +189

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An easier solution would be to ignore those channels temporarily, they can still be picked up next time uncertainty_network_update is called again.

Suggested change
/* This can happen transiently if gossipd is
* writing it to the store right now. Set
* it to larger htlc_max */
cap_msat = AMOUNT_MSAT(0);
for (int dir = 0; dir < 2; dir++)
{
struct amount_msat htlc_max;
if (!gossmap_chan_set(chan, dir))
continue;
htlc_max = amount_msat(fp16_to_u64(chan->half[dir].htlc_max));
if (amount_msat_greater(htlc_max, cap_msat))
cap_msat = htlc_max;
}
plugin_log(pay_plugin->plugin, LOG_UNUSUAL,
"Cannot fetch capacity for channel %s: using %s",
fmt_short_channel_id(tmpctx, scid),
fmt_amount_msat(tmpctx, cap_msat));
/* This can happen transiently if gossipd is
* writing it to the store right now.
* Ignore this channel for the moment, we can
* pick it up next time. */
plugin_log(pay_plugin->plugin, LOG_UNUSUAL,
"Cannot fetch capacity for channel %s: skipping it.",
fmt_short_channel_id(tmpctx, scid));

The only issue I can think of right now, is that we will have some channels in gossmap that have no counterpart in chan_extra_map and we would have to handle this case when the MCF graph is built (init_linear_network in mcf.c assumes that).

}
if(!amount_sat_to_msat(&cap_msat,cap))
else if(!amount_sat_to_msat(&cap_msat,cap))
{
plugin_err(pay_plugin->plugin,"%s (line %d) unable convert sat to msat",
__PRETTY_FUNCTION__,
__LINE__);
__PRETTY_FUNCTION__,
__LINE__);
}
new_chan_extra(chan_extra_map,scid,cap_msat);
}
Expand Down