Skip to content

Commit cae35fc

Browse files
committed
pay: Log the exclusion for most expensive and highest delay
We are looking into a couple of issues that are related to channels being excluded when the fee or delay budget is exceeded. For this it would be very useful to learn how we came to exclude a given channel.
1 parent 49062c1 commit cae35fc

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

Diff for: plugins/libplugin-pay.c

+33-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "bitcoin/short_channel_id.h"
12
#include "config.h"
23
#include <ccan/array_size/array_size.h>
34
#include <ccan/tal/str/str.h>
@@ -402,15 +403,29 @@ static void payment_exclude_most_expensive(struct payment *p)
402403
struct route_hop *e = &p->route[0];
403404
struct amount_msat fee, worst = AMOUNT_MSAT(0);
404405

405-
for (size_t i = 0; i < tal_count(p->route)-1; i++) {
406+
paymod_log(p, LOG_DBG,
407+
"Searching for most expensive channel to exclude in route");
408+
for (size_t i = 0; i < tal_count(p->route) - 1; i++) {
406409
if (!amount_msat_sub(&fee, p->route[i].amount, p->route[i+1].amount))
407410
paymod_err(p, "Negative fee in a route.");
408411

409412
if (amount_msat_greater_eq(fee, worst)) {
413+
paymod_log(
414+
p, LOG_DBG, "Found worse channel: %s >= %s (%s/%d)",
415+
type_to_string(tmpctx, struct amount_msat, &fee),
416+
type_to_string(tmpctx, struct amount_msat, &worst),
417+
type_to_string(tmpctx, struct short_channel_id,
418+
&p->route[i].scid),
419+
p->route[i].direction);
410420
e = &p->route[i];
411421
worst = fee;
412422
}
413423
}
424+
paymod_log(p, LOG_DBG,
425+
"Excluding %s/%d as the most expensive channel in the route",
426+
type_to_string(tmpctx, struct short_channel_id, &e->scid),
427+
e->direction);
428+
414429
channel_hints_update(p, e->scid, e->direction, false, false,
415430
NULL, NULL);
416431
}
@@ -420,15 +435,29 @@ static void payment_exclude_longest_delay(struct payment *p)
420435
struct route_hop *e = &p->route[0];
421436
u32 delay, worst = 0;
422437

423-
for (size_t i = 0; i < tal_count(p->route)-1; i++) {
438+
paymod_log(p, LOG_DBG,
439+
"Searching for longest delay channel to exclude in route");
440+
for (size_t i = 0; i < tal_count(p->route) - 1; i++) {
424441
delay = p->route[i].delay - p->route[i+1].delay;
425442
if (delay >= worst) {
443+
paymod_log(
444+
p, LOG_DBG, "Found worse channel: %d >= %d (%s/%d)",
445+
delay, worst,
446+
type_to_string(tmpctx, struct short_channel_id,
447+
&p->route[i].scid),
448+
p->route[i].direction);
426449
e = &p->route[i];
427450
worst = delay;
428451
}
429452
}
430-
channel_hints_update(p, e->scid, e->direction, false, false,
431-
NULL, NULL);
453+
454+
paymod_log(p, LOG_DBG,
455+
"Excluding %s/%d as the most expensive channel in the route",
456+
type_to_string(tmpctx, struct short_channel_id, &e->scid),
457+
e->direction);
458+
459+
channel_hints_update(p, e->scid, e->direction, false, false, NULL,
460+
NULL);
432461
}
433462

434463
static struct amount_msat payment_route_fee(struct payment *p)

0 commit comments

Comments
 (0)