Skip to content

Commit 7db6aaa

Browse files
committed
renepay: clarify chan_extra_can_send.
I am doing to add more more debugging, but sent here is 0. Document that clearly, and put a real value in sent. Also: since we already sub 1 msat from x, amount_msat_less_eq should be amount_msat_less (it may be equal to our min, in theory). Signed-off-by: Rusty Russell <[email protected]>
1 parent 7287ade commit 7db6aaa

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

plugins/renepay/flow.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,14 @@ void chan_extra_can_send(
143143
chan_extra_can_send_(ce,scidd->dir,x);
144144
}
145145

146-
/* Update the knowledge that this (channel,direction) cannot send x msat.*/
146+
/* Update the knowledge that this (channel,direction) cannot send.*/
147147
void chan_extra_cannot_send(
148148
struct payment *p,
149149
struct chan_extra_map *chan_extra_map,
150150
const struct short_channel_id_dir *scidd,
151-
struct amount_msat x)
151+
struct amount_msat sent)
152152
{
153+
struct amount_msat x;
153154
struct chan_extra *ce = chan_extra_map_get(chan_extra_map,
154155
scidd->scid);
155156
if(!ce)
@@ -158,27 +159,19 @@ void chan_extra_cannot_send(
158159
__PRETTY_FUNCTION__,__LINE__);
159160
}
160161

161-
/* If a channel cannot send x it means that the upper bound for the
162-
* liquidity is MAX_L < x + htlc_total */
163-
if(!amount_msat_add(&x,x,ce->half[scidd->dir].htlc_total))
164-
{
165-
debug_err("%s (line %d) cannot add x=%s and htlc_total=%s",
166-
__PRETTY_FUNCTION__,__LINE__,
167-
type_to_string(tmpctx,struct amount_msat,&x),
168-
type_to_string(tmpctx,struct amount_msat,&ce->half[scidd->dir].htlc_total));
169-
}
170-
171-
if(!amount_msat_sub(&x,x,AMOUNT_MSAT(1)))
162+
/* Note: sent is already included in htlc_total! */
163+
if(!amount_msat_sub(&x,ce->half[scidd->dir].htlc_total,AMOUNT_MSAT(1)))
172164
{
173-
debug_err("%s (line %d) unexpected x=%s is less than 0msat",
165+
debug_err("%s (line %d) unexpected htlc_total=%s is less than 0msat",
174166
__PRETTY_FUNCTION__,__LINE__,
175-
type_to_string(tmpctx,struct amount_msat,&x)
167+
type_to_string(tmpctx,struct amount_msat,
168+
&ce->half[scidd->dir].htlc_total)
176169
);
177170
x = AMOUNT_MSAT(0);
178171
}
179172

180173
/* If we "knew" the capacity was at least this, we just showed we're wrong! */
181-
if (amount_msat_less_eq(x, ce->half[scidd->dir].known_min)) {
174+
if (amount_msat_less(x, ce->half[scidd->dir].known_min)) {
182175
debug_paynote(p, "Expected scid=%s min %s, but %s failed! Setting min to 0",
183176
type_to_string(tmpctx,struct short_channel_id_dir,scidd),
184177
type_to_string(tmpctx,struct amount_msat,&ce->half[scidd->dir].known_min),

plugins/renepay/pay.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,11 +1190,7 @@ static void handle_sendpay_failure_flow(struct pay_flow *pf,
11901190

11911191
chan_extra_cannot_send(p,pay_plugin->chan_extra_map,
11921192
&pf->path_scidds[erridx],
1193-
/* This channel can't send all that was
1194-
* commited in HTLCs.
1195-
* Had we removed the commited amount then
1196-
* we would have to put here pf->amounts[erridx]. */
1197-
AMOUNT_MSAT(0));
1193+
pf->amounts[erridx]);
11981194
}
11991195
}
12001196

0 commit comments

Comments
 (0)