mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
remove unnecessary arguments
Functions chan_extra_can_send and chan_extra_cannot_send do not need to know the amount, because flow is already allocated in htlc_total.
This commit is contained in:
parent
feef829362
commit
7edf3c2a55
@ -225,7 +225,7 @@ static bool chan_extra_can_send_(const tal_t *ctx, struct chan_extra *ce,
|
||||
bool chan_extra_can_send(const tal_t *ctx,
|
||||
struct chan_extra_map *chan_extra_map,
|
||||
const struct short_channel_id_dir *scidd,
|
||||
struct amount_msat x, char **fail)
|
||||
char **fail)
|
||||
{
|
||||
assert(scidd);
|
||||
assert(chan_extra_map);
|
||||
@ -235,16 +235,8 @@ bool chan_extra_can_send(const tal_t *ctx,
|
||||
*fail = chan_extra_not_found_error(ctx, &scidd->scid);
|
||||
goto function_fail;
|
||||
}
|
||||
if (!amount_msat_add(&x, x, ce->half[scidd->dir].htlc_total)) {
|
||||
if(fail)
|
||||
*fail =
|
||||
tal_fmt(ctx, "cannot add x=%s and htlc_total=%s",
|
||||
type_to_string(ctx, struct amount_msat, &x),
|
||||
type_to_string(ctx, struct amount_msat,
|
||||
&ce->half[scidd->dir].htlc_total));
|
||||
goto function_fail;
|
||||
}
|
||||
if (!chan_extra_can_send_(ctx, ce, scidd->dir, x, fail)) {
|
||||
if (!chan_extra_can_send_(ctx, ce, scidd->dir,
|
||||
ce->half[scidd->dir].htlc_total, fail)) {
|
||||
goto function_fail;
|
||||
}
|
||||
return true;
|
||||
@ -257,7 +249,7 @@ bool chan_extra_can_send(const tal_t *ctx,
|
||||
bool chan_extra_cannot_send(const tal_t *ctx,
|
||||
struct chan_extra_map *chan_extra_map,
|
||||
const struct short_channel_id_dir *scidd,
|
||||
struct amount_msat sent, char **fail)
|
||||
char **fail)
|
||||
{
|
||||
assert(scidd);
|
||||
assert(chan_extra_map);
|
||||
@ -395,6 +387,16 @@ bool chan_extra_sent_success(const tal_t *ctx,
|
||||
assert(chan_extra_map);
|
||||
tal_t *this_ctx = tal(ctx, tal_t);
|
||||
char *errmsg;
|
||||
|
||||
// if we sent amount x, it first means that all htlcs on this channel fit
|
||||
// in the liquidity
|
||||
if (!chan_extra_can_send(this_ctx, chan_extra_map, scidd, &errmsg)) {
|
||||
if (fail)
|
||||
*fail = tal_fmt(ctx, "chan_extra_can_send failed: %s",
|
||||
errmsg);
|
||||
goto function_fail;
|
||||
}
|
||||
|
||||
struct chan_extra *ce = chan_extra_map_get(chan_extra_map, scidd->scid);
|
||||
if (!ce) {
|
||||
if(fail)
|
||||
|
@ -150,13 +150,13 @@ static inline struct amount_msat amount_msat_max(
|
||||
bool chan_extra_can_send(const tal_t *ctx,
|
||||
struct chan_extra_map *chan_extra_map,
|
||||
const struct short_channel_id_dir *scidd,
|
||||
struct amount_msat x, char **fail);
|
||||
char **fail);
|
||||
|
||||
/* Update the knowledge that this (channel,direction) cannot send x msat.*/
|
||||
bool chan_extra_cannot_send(const tal_t *ctx,
|
||||
struct chan_extra_map *chan_extra_map,
|
||||
const struct short_channel_id_dir *scidd,
|
||||
struct amount_msat sent, char **fail);
|
||||
char **fail);
|
||||
|
||||
/* Update the knowledge that this (channel,direction) has liquidity x.*/
|
||||
bool chan_extra_set_liquidity(const tal_t *ctx,
|
||||
|
@ -1132,7 +1132,7 @@ static void handle_sendpay_failure_flow(struct pay_flow *pf,
|
||||
char *fail;
|
||||
if (!chan_extra_cannot_send(tmpctx, pay_plugin->chan_extra_map,
|
||||
&pf->path_scidds[erridx],
|
||||
pf->amounts[erridx], &fail)) {
|
||||
&fail)) {
|
||||
plugin_err(pay_plugin->plugin,
|
||||
"chan_extra_cannot_send failed: %s", fail);
|
||||
}
|
||||
|
@ -227,11 +227,7 @@ void uncertainty_network_channel_can_send(
|
||||
{
|
||||
if (!chan_extra_can_send(
|
||||
tmpctx, chan_extra_map, &pf->path_scidds[i],
|
||||
/* This channel can send all that was
|
||||
* commited in HTLCs.
|
||||
* Had we removed the commited amount then
|
||||
* we would have to put here pf->amounts[i]. */
|
||||
AMOUNT_MSAT(0), &fail)) {
|
||||
&fail)) {
|
||||
plugin_err(pay_plugin->plugin,
|
||||
"chan_extra_can_send failed: %s", fail);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user