5
5
#include <ccan/tal/tal.h>
6
6
#include <common/type_to_string.h>
7
7
#include <math.h>
8
- #include <plugins/renepay/debug.h>
9
8
#include <plugins/renepay/flow.h>
9
+ #include <plugins/renepay/pay.h>
10
10
#include <stdio.h>
11
11
12
12
#ifndef SUPERVERBOSE
@@ -128,15 +128,16 @@ void chan_extra_adjust_half(struct chan_extra *ce,
128
128
{
129
129
if (!amount_msat_sub (& ce -> half [dir ].known_max ,ce -> capacity ,ce -> half [!dir ].known_min ))
130
130
{
131
- debug_err ("%s cannot substract capacity=%s and known_min=%s" ,
131
+ plugin_err (pay_plugin -> plugin ,
132
+ "%s cannot substract capacity=%s and known_min=%s" ,
132
133
__PRETTY_FUNCTION__ ,
133
134
type_to_string (tmpctx ,struct amount_msat ,& ce -> capacity ),
134
135
type_to_string (tmpctx ,struct amount_msat ,& ce -> half [!dir ].known_min )
135
136
);
136
137
}
137
138
if (!amount_msat_sub (& ce -> half [dir ].known_min ,ce -> capacity ,ce -> half [!dir ].known_max ))
138
139
{
139
- debug_err ( "%s cannot substract capacity=%s and known_max=%s" ,
140
+ plugin_err ( pay_plugin -> plugin , "%s cannot substract capacity=%s and known_max=%s" ,
140
141
__PRETTY_FUNCTION__ ,
141
142
type_to_string (tmpctx ,struct amount_msat ,& ce -> capacity ),
142
143
type_to_string (tmpctx ,struct amount_msat ,& ce -> half [!dir ].known_max )
@@ -153,7 +154,7 @@ static void chan_extra_can_send_(
153
154
{
154
155
if (amount_msat_greater (x ,ce -> capacity ))
155
156
{
156
- debug_err ( "%s unexpected capacity=%s is less than x=%s" ,
157
+ plugin_err ( pay_plugin -> plugin , "%s unexpected capacity=%s is less than x=%s" ,
157
158
__PRETTY_FUNCTION__ ,
158
159
type_to_string (tmpctx ,struct amount_msat ,& ce -> capacity ),
159
160
type_to_string (tmpctx ,struct amount_msat ,& x )
@@ -176,12 +177,12 @@ void chan_extra_can_send(
176
177
scidd -> scid );
177
178
if (!ce )
178
179
{
179
- debug_err ( "%s unexpected chan_extra ce is NULL" ,
180
+ plugin_err ( pay_plugin -> plugin , "%s unexpected chan_extra ce is NULL" ,
180
181
__PRETTY_FUNCTION__ );
181
182
}
182
183
if (!amount_msat_add (& x ,x ,ce -> half [scidd -> dir ].htlc_total ))
183
184
{
184
- debug_err ( "%s (line %d) cannot add x=%s and htlc_total=%s" ,
185
+ plugin_err ( pay_plugin -> plugin , "%s (line %d) cannot add x=%s and htlc_total=%s" ,
185
186
__PRETTY_FUNCTION__ ,__LINE__ ,
186
187
type_to_string (tmpctx ,struct amount_msat ,& x ),
187
188
type_to_string (tmpctx ,struct amount_msat ,& ce -> half [scidd -> dir ].htlc_total ));
@@ -201,14 +202,14 @@ void chan_extra_cannot_send(
201
202
scidd -> scid );
202
203
if (!ce )
203
204
{
204
- debug_err ( "%s (line %d) unexpected chan_extra ce is NULL" ,
205
+ plugin_err ( pay_plugin -> plugin , "%s (line %d) unexpected chan_extra ce is NULL" ,
205
206
__PRETTY_FUNCTION__ ,__LINE__ );
206
207
}
207
208
208
209
/* Note: sent is already included in htlc_total! */
209
210
if (!amount_msat_sub (& x ,ce -> half [scidd -> dir ].htlc_total ,AMOUNT_MSAT (1 )))
210
211
{
211
- debug_err ( "%s (line %d) unexpected htlc_total=%s is less than 0msat" ,
212
+ plugin_err ( pay_plugin -> plugin , "%s (line %d) unexpected htlc_total=%s is less than 0msat" ,
212
213
__PRETTY_FUNCTION__ ,__LINE__ ,
213
214
type_to_string (tmpctx ,struct amount_msat ,
214
215
& ce -> half [scidd -> dir ].htlc_total )
@@ -246,7 +247,7 @@ static void chan_extra_set_liquidity_(
246
247
{
247
248
if (amount_msat_greater (x ,ce -> capacity ))
248
249
{
249
- debug_err ( "%s unexpected capacity=%s is less than x=%s" ,
250
+ plugin_err ( pay_plugin -> plugin , "%s unexpected capacity=%s is less than x=%s" ,
250
251
__PRETTY_FUNCTION__ ,
251
252
type_to_string (tmpctx ,struct amount_msat ,& ce -> capacity ),
252
253
type_to_string (tmpctx ,struct amount_msat ,& x )
@@ -268,7 +269,7 @@ void chan_extra_set_liquidity(
268
269
scidd -> scid );
269
270
if (!ce )
270
271
{
271
- debug_err ( "%s unexpected chan_extra ce is NULL" ,
272
+ plugin_err ( pay_plugin -> plugin , "%s unexpected chan_extra ce is NULL" ,
272
273
__PRETTY_FUNCTION__ );
273
274
}
274
275
chan_extra_set_liquidity_ (ce ,scidd -> dir ,x );
@@ -284,13 +285,13 @@ void chan_extra_sent_success(
284
285
scidd -> scid );
285
286
if (!ce )
286
287
{
287
- debug_err ( "%s unexpected chan_extra ce is NULL" ,
288
+ plugin_err ( pay_plugin -> plugin , "%s unexpected chan_extra ce is NULL" ,
288
289
__PRETTY_FUNCTION__ );
289
290
}
290
291
291
292
if (amount_msat_greater (x ,ce -> capacity ))
292
293
{
293
- debug_err ( "%s unexpected capacity=%s is less than x=%s" ,
294
+ plugin_err ( pay_plugin -> plugin , "%s unexpected capacity=%s is less than x=%s" ,
294
295
__PRETTY_FUNCTION__ ,
295
296
type_to_string (tmpctx ,struct amount_msat ,& ce -> capacity ),
296
297
type_to_string (tmpctx ,struct amount_msat ,& x )
@@ -349,7 +350,7 @@ void chan_extra_relax(
349
350
scidd -> scid );
350
351
if (!ce )
351
352
{
352
- debug_err ( "%s unexpected chan_extra ce is NULL" ,
353
+ plugin_err ( pay_plugin -> plugin , "%s unexpected chan_extra ce is NULL" ,
353
354
__PRETTY_FUNCTION__ );
354
355
}
355
356
chan_extra_relax_ (ce ,scidd -> dir ,x ,y );
@@ -427,7 +428,7 @@ get_chan_extra_half_by_chan_verify(
427
428
if (!gossmap_chan_get_capacity (gossmap ,chan , & cap ) ||
428
429
!amount_sat_to_msat (& cap_msat , cap ))
429
430
{
430
- debug_err ( "%s (line %d) unable convert sat to msat or "
431
+ plugin_err ( pay_plugin -> plugin , "%s (line %d) unable convert sat to msat or "
431
432
"get channel capacity" ,
432
433
__PRETTY_FUNCTION__ ,
433
434
__LINE__ );
@@ -488,7 +489,7 @@ static double edge_probability(struct amount_msat min, struct amount_msat max,
488
489
// one past the last known value, makes computations simpler
489
490
if (!amount_msat_add (& B ,B ,one ))
490
491
{
491
- debug_err ( "%s (line %d) cannot add B=%s and %s" ,
492
+ plugin_err ( pay_plugin -> plugin , "%s (line %d) cannot add B=%s and %s" ,
492
493
__PRETTY_FUNCTION__ ,
493
494
__LINE__ ,
494
495
type_to_string (this_ctx , struct amount_msat , & B ),
@@ -497,7 +498,7 @@ static double edge_probability(struct amount_msat min, struct amount_msat max,
497
498
// in_flight cannot be greater than max
498
499
if (!amount_msat_sub (& B ,B ,in_flight ))
499
500
{
500
- debug_err ( "%s (line %d) in_flight=%s cannot be greater than B=%s" ,
501
+ plugin_err ( pay_plugin -> plugin , "%s (line %d) in_flight=%s cannot be greater than B=%s" ,
501
502
__PRETTY_FUNCTION__ ,
502
503
__LINE__ ,
503
504
type_to_string (this_ctx , struct amount_msat , & in_flight ),
@@ -513,7 +514,7 @@ static double edge_probability(struct amount_msat min, struct amount_msat max,
513
514
// B cannot be smaller than or equal A
514
515
if (!amount_msat_sub (& denominator ,B ,A ) || amount_msat_less_eq (B ,A ))
515
516
{
516
- debug_err ( "%s (line %d) B=%s must be greater than A=%s" ,
517
+ plugin_err ( pay_plugin -> plugin , "%s (line %d) B=%s must be greater than A=%s" ,
517
518
__PRETTY_FUNCTION__ ,
518
519
__LINE__ ,
519
520
type_to_string (this_ctx , struct amount_msat , & B ),
@@ -545,7 +546,7 @@ void remove_completed_flow(const struct gossmap *gossmap,
545
546
flow -> dirs [i ]);
546
547
if (!amount_msat_sub (& h -> htlc_total , h -> htlc_total , flow -> amounts [i ]))
547
548
{
548
- debug_err ( "%s could not substract HTLC amounts, "
549
+ plugin_err ( pay_plugin -> plugin , "%s could not substract HTLC amounts, "
549
550
"half total htlc amount = %s, "
550
551
"flow->amounts[%lld] = %s." ,
551
552
__PRETTY_FUNCTION__ ,
@@ -555,7 +556,7 @@ void remove_completed_flow(const struct gossmap *gossmap,
555
556
}
556
557
if (h -> num_htlcs == 0 )
557
558
{
558
- debug_err ( "%s could not decrease HTLC count." ,
559
+ plugin_err ( pay_plugin -> plugin , "%s could not decrease HTLC count." ,
559
560
__PRETTY_FUNCTION__ );
560
561
}
561
562
h -> num_htlcs -- ;
@@ -586,7 +587,7 @@ void commit_flow(
586
587
flow -> dirs [i ]);
587
588
if (!amount_msat_add (& h -> htlc_total , h -> htlc_total , flow -> amounts [i ]))
588
589
{
589
- debug_err ( "%s could not add HTLC amounts, "
590
+ plugin_err ( pay_plugin -> plugin , "%s could not add HTLC amounts, "
590
591
"flow->amounts[%lld] = %s." ,
591
592
__PRETTY_FUNCTION__ ,
592
593
i ,
@@ -631,7 +632,7 @@ void flow_complete(struct flow *flow,
631
632
632
633
if (!h )
633
634
{
634
- debug_err ( "%s unexpected chan_extra_half is NULL" ,
635
+ plugin_err ( pay_plugin -> plugin , "%s unexpected chan_extra_half is NULL" ,
635
636
__PRETTY_FUNCTION__ );
636
637
}
637
638
@@ -645,7 +646,7 @@ void flow_complete(struct flow *flow,
645
646
flow_edge (flow , i )-> base_fee ,
646
647
flow_edge (flow , i )-> proportional_fee ))
647
648
{
648
- debug_err ( "%s fee overflow" ,
649
+ plugin_err ( pay_plugin -> plugin , "%s fee overflow" ,
649
650
__PRETTY_FUNCTION__ );
650
651
}
651
652
}
@@ -716,7 +717,7 @@ double flow_set_probability(
716
717
struct amount_msat prev_flow ;
717
718
if (!amount_msat_add (& prev_flow ,h -> htlc_total ,in_flight [c_idx ].half [c_dir ]))
718
719
{
719
- debug_err ( "%s (line %d) in-flight amount_msat overflow" ,
720
+ plugin_err ( pay_plugin -> plugin , "%s (line %d) in-flight amount_msat overflow" ,
720
721
__PRETTY_FUNCTION__ ,
721
722
__LINE__ );
722
723
}
@@ -728,7 +729,7 @@ double flow_set_probability(
728
729
in_flight [c_idx ].half [c_dir ],
729
730
deliver ))
730
731
{
731
- debug_err ( "%s (line %d) in-flight amount_msat overflow" ,
732
+ plugin_err ( pay_plugin -> plugin , "%s (line %d) in-flight amount_msat overflow" ,
732
733
__PRETTY_FUNCTION__ ,
733
734
__LINE__ );
734
735
}
@@ -810,7 +811,7 @@ static void get_medians(const struct gossmap *gossmap,
810
811
* median_capacity = amount ;
811
812
else if (!amount_sat_to_msat (median_capacity , caps [num_caps / 2 ]))
812
813
{
813
- debug_err ( "%s (line %d) amount_msat overflow" ,
814
+ plugin_err ( pay_plugin -> plugin , "%s (line %d) amount_msat overflow" ,
814
815
__PRETTY_FUNCTION__ ,
815
816
__LINE__ );
816
817
}
@@ -877,13 +878,13 @@ struct amount_msat flow_set_fee(struct flow **flows)
877
878
flows [i ]-> amounts [0 ],
878
879
flows [i ]-> amounts [n - 1 ]))
879
880
{
880
- debug_err ( "%s (line %d) amount_msat overflow" ,
881
+ plugin_err ( pay_plugin -> plugin , "%s (line %d) amount_msat overflow" ,
881
882
__PRETTY_FUNCTION__ ,
882
883
__LINE__ );
883
884
}
884
885
if (!amount_msat_add (& fee , this_fee ,fee ))
885
886
{
886
- debug_err ( "%s (line %d) amount_msat overflow" ,
887
+ plugin_err ( pay_plugin -> plugin , "%s (line %d) amount_msat overflow" ,
887
888
__PRETTY_FUNCTION__ ,
888
889
__LINE__ );
889
890
}
0 commit comments