Skip to content

Commit 32f5ae8

Browse files
committed
renepay: remove remaining calls to debug_paynote in favor of payflow_note().
Some are redundant, others simply convert. Signed-off-by: Rusty Russell <[email protected]>
1 parent 574716d commit 32f5ae8

File tree

4 files changed

+26
-42
lines changed

4 files changed

+26
-42
lines changed

plugins/renepay/debug.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ void _debug_exec_branch(const char* fname,const char* fun, int lineno);
3030
#define debug_err(...) \
3131
{_debug_info(MYLOG,__VA_ARGS__); abort();}
3232

33-
#define debug_paynote(p,...) \
34-
{payment_note(p,LOG_INFORM,__VA_ARGS__);_debug_info(MYLOG,__VA_ARGS__);}
35-
3633
#else
3734
/* Debugging information goes either to payment notes or to lightningd log. */
3835

@@ -42,9 +39,6 @@ void _debug_exec_branch(const char* fname,const char* fun, int lineno);
4239
#define debug_err(...) \
4340
plugin_err(pay_plugin->plugin,__VA_ARGS__)
4441

45-
#define debug_paynote(p,...) \
46-
payment_note(p,LOG_INFORM,__VA_ARGS__);
47-
4842
#endif
4943

5044
#define debug_assert(expr) \

plugins/renepay/pay.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,25 +1046,18 @@ static struct pf_result *handle_sendpay_failure_payment(struct pay_flow *pf STEA
10461046
const u8 *raw)
10471047
{
10481048
struct short_channel_id errscid;
1049-
struct payment *p = pf->payment;
10501049
const u8 *update;
10511050

10521051
debug_assert(pf);
1053-
debug_assert(p);
10541052

10551053
/* Final node is usually a hard failure */
10561054
if (erridx == tal_count(pf->path_scidds)) {
1057-
debug_paynote(p,
1058-
"onion error %s from final node #%u: %s",
1059-
onion_wire_name(onionerr),
1060-
erridx,
1061-
message);
1062-
10631055
if (onionerr == WIRE_MPP_TIMEOUT) {
10641056
return pay_flow_failed(pf);
10651057
}
10661058

1067-
debug_paynote(p,"final destination failure");
1059+
payflow_note(pf, LOG_INFORM,
1060+
"final destination permanent failure");
10681061
return pay_flow_failed_final(pf, PAY_DESTINATION_PERM_FAIL, message);
10691062
}
10701063

@@ -1229,8 +1222,6 @@ static struct pf_result *sendpay_failure(struct pay_flow *pf,
12291222
/* Only one code is really actionable */
12301223
switch (errcode) {
12311224
case PAY_UNPARSEABLE_ONION:
1232-
debug_paynote(pf->payment, "Unparsable onion reply on route %s",
1233-
flow_path_to_str(tmpctx, pf));
12341225
return handle_unhandleable_error(pf, "Unparsable onion reply");
12351226

12361227
case PAY_TRY_OTHER_ROUTE:

plugins/renepay/pay_flow.c

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,12 @@ static u32 *shadow_additions(const tal_t *ctx,
220220
shadow_delay = shadow_one_flow(gossmap, flows[i],
221221
&shadow_fee);
222222
if (flow_delay(flows[i]) + shadow_delay > p->maxdelay) {
223-
debug_paynote(p, "No shadow for flow %zu/%zu:"
224-
" delay would add %u to %"PRIu64", exceeding max delay.",
225-
i, tal_count(flows),
226-
shadow_delay,
227-
flow_delay(flows[i]));
223+
payment_note(p, LOG_UNUSUAL,
224+
"No shadow for flow %zu/%zu:"
225+
" delay would add %u to %"PRIu64", exceeding max delay.",
226+
i, tal_count(flows),
227+
shadow_delay,
228+
flow_delay(flows[i]));
228229
continue;
229230
}
230231

@@ -235,7 +236,8 @@ static u32 *shadow_additions(const tal_t *ctx,
235236
if (is_entire_payment && tal_count(flows) == 1) {
236237
if (!add_to_amounts(gossmap, flows[i], p->maxspend,
237238
shadow_fee)) {
238-
debug_paynote(p, "No shadow fee for flow %zu/%zu:"
239+
payment_note(p, LOG_UNUSUAL,
240+
"No shadow fee for flow %zu/%zu:"
239241
" fee would add %s to %s, exceeding budget %s.",
240242
i, tal_count(flows),
241243
type_to_string(tmpctx, struct amount_msat,
@@ -245,7 +247,8 @@ static u32 *shadow_additions(const tal_t *ctx,
245247
type_to_string(tmpctx, struct amount_msat,
246248
&p->maxspend));
247249
} else {
248-
debug_paynote(p, "No MPP, so added %s shadow fee",
250+
payment_note(p, LOG_DBG,
251+
"No MPP, so added %s shadow fee",
249252
type_to_string(tmpctx, struct amount_msat,
250253
&shadow_fee));
251254
}
@@ -444,13 +447,11 @@ const char *add_payflows(const tal_t *ctx,
444447
disabled = make_disabled_bitmap(tmpctx, pay_plugin->gossmap, p->disabled_scids);
445448
src = gossmap_find_node(pay_plugin->gossmap, &pay_plugin->my_id);
446449
if (!src) {
447-
debug_paynote(p, "We don't have any channels?");
448450
*ecode = PAY_ROUTE_NOT_FOUND;
449451
return tal_fmt(ctx, "We don't have any channels.");
450452
}
451453
dst = gossmap_find_node(pay_plugin->gossmap, &p->destination);
452454
if (!dst) {
453-
debug_paynote(p, "No trace of destination in network gossip");
454455
*ecode = PAY_ROUTE_NOT_FOUND;
455456
return tal_fmt(ctx, "Destination is unknown in the network gossip.");
456457
}
@@ -472,10 +473,6 @@ const char *add_payflows(const tal_t *ctx,
472473
p->base_fee_penalty,
473474
p->prob_cost_factor);
474475
if (!flows) {
475-
debug_paynote(p,
476-
"minflow couldn't find a feasible flow for %s",
477-
type_to_string(tmpctx,struct amount_msat,&amount));
478-
479476
*ecode = PAY_ROUTE_NOT_FOUND;
480477
return tal_fmt(ctx,
481478
"minflow couldn't find a feasible flow for %s",
@@ -487,7 +484,7 @@ const char *add_payflows(const tal_t *ctx,
487484
fee = flow_set_fee(flows);
488485
delay = flows_worst_delay(flows) + p->final_cltv;
489486

490-
debug_paynote(p,
487+
payment_note(p, LOG_INFORM,
491488
"we have computed a set of %ld flows with probability %.3lf, fees %s and delay %ld",
492489
tal_count(flows),
493490
prob,
@@ -497,9 +494,6 @@ const char *add_payflows(const tal_t *ctx,
497494
too_expensive = amount_msat_greater(fee, feebudget);
498495
if (too_expensive)
499496
{
500-
debug_paynote(p, "Flows too expensive, fee = %s (max %s)",
501-
type_to_string(tmpctx, struct amount_msat, &fee),
502-
type_to_string(tmpctx, struct amount_msat, &feebudget));
503497
*ecode = PAY_ROUTE_TOO_EXPENSIVE;
504498
return tal_fmt(ctx,
505499
"Fee exceeds our fee budget, "
@@ -509,12 +503,8 @@ const char *add_payflows(const tal_t *ctx,
509503
}
510504
too_delayed = (delay > p->maxdelay);
511505
if (too_delayed) {
512-
debug_paynote(p, "Flows too delayed, delay = %"PRIu64" (max %u)",
513-
delay, p->maxdelay);
514-
515506
/* FIXME: What is a sane limit? */
516507
if (p->delay_feefactor > 1000) {
517-
debug_paynote(p, "Giving up!");
518508
*ecode = PAY_ROUTE_TOO_EXPENSIVE;
519509
return tal_fmt(ctx,
520510
"CLTV delay exceeds our CLTV budget, "
@@ -523,8 +513,10 @@ const char *add_payflows(const tal_t *ctx,
523513
}
524514

525515
p->delay_feefactor *= 2;
526-
debug_paynote(p, "Doubling delay_feefactor to %f",
527-
p->delay_feefactor);
516+
payment_note(p, LOG_INFORM,
517+
"delay %"PRIu64" exceeds our max %u, so doubling delay_feefactor to %f",
518+
delay, p->maxdelay,
519+
p->delay_feefactor);
528520

529521
continue; // retry
530522
}

plugins/renepay/payment.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ struct command_result *payment_fail(
217217
enum jsonrpc_errcode code,
218218
const char *fmt, ...)
219219
{
220+
struct command *cmd;
221+
220222
/* We usually get called because a flow failed, but we
221223
* can also get called because we couldn't route any more
222224
* or some strange error. */
@@ -231,9 +233,14 @@ struct command_result *payment_fail(
231233
char *message = tal_vfmt(tmpctx,fmt,args);
232234
va_end(args);
233235

234-
debug_paynote(payment,"%s",message);
236+
/* Don't bother notifying command, it's about to get failure */
237+
cmd = payment->cmd;
238+
payment->cmd = NULL;
239+
payment_note(payment, LOG_DBG, "%s", message);
240+
/* Restore to keep destructor happy! */
241+
payment->cmd = cmd;
235242

236-
return command_fail(payment->cmd,code,"%s",message);
243+
return command_fail(cmd,code,"%s",message);
237244
}
238245

239246
u64 payment_parts(const struct payment *payment)

0 commit comments

Comments
 (0)