Skip to content

Commit

Permalink
remove is_local variable from listpeerchannels cb
Browse files Browse the repository at this point in the history
is_local, ie. "is this side of the channel ours?" is not needed since we
can determine that predicate by evaluating
`scidd->dir == node_id_idx(self, peer)`
  • Loading branch information
Lagrang3 committed Apr 2, 2024
1 parent d94d15d commit e5c705f
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 17 deletions.
6 changes: 2 additions & 4 deletions common/gossmods_listpeerchannels.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ void gossmod_add_localchan(struct gossmap_localmods *mods,
u32 fee_proportional,
u32 cltv_delta,
bool enabled,
bool is_local UNUSED,
const char *buf UNUSED,
const jsmntok_t *chantok UNUSED,
void *cbarg UNUSED)
Expand Down Expand Up @@ -54,7 +53,6 @@ gossmods_from_listpeerchannels_(const tal_t *ctx,
u32 fee_proportional,
u32 cltv_delta,
bool enabled,
bool is_local,
const char *buf,
const jsmntok_t *chantok,
void *cbarg),
Expand Down Expand Up @@ -152,7 +150,7 @@ gossmods_from_listpeerchannels_(const tal_t *ctx,
/* We add both directions */
cb(mods, self, &dst, &scidd, htlc_min[LOCAL], htlc_max[LOCAL],
spendable, fee_base[LOCAL], fee_proportional[LOCAL],
cltv_delta[LOCAL], enabled, true, buf, channel, cbarg);
cltv_delta[LOCAL], enabled, buf, channel, cbarg);

/* If we didn't have a remote update, it's not usable yet */
if (fee_proportional[REMOTE] == -1U)
Expand All @@ -162,7 +160,7 @@ gossmods_from_listpeerchannels_(const tal_t *ctx,

cb(mods, self, &dst, &scidd, htlc_min[REMOTE], htlc_max[REMOTE],
receivable, fee_base[REMOTE], fee_proportional[REMOTE],
cltv_delta[REMOTE], enabled, false, buf, channel, cbarg);
cltv_delta[REMOTE], enabled, buf, channel, cbarg);
}

return mods;
Expand Down
3 changes: 0 additions & 3 deletions common/gossmods_listpeerchannels.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ struct gossmap_localmods *gossmods_from_listpeerchannels_(const tal_t *ctx,
u32 fee_proportional,
u32 cltv_delta,
bool enabled,
bool is_local,
const char *buf_,
const jsmntok_t *chantok,
void *cbarg_),
Expand All @@ -57,7 +56,6 @@ struct gossmap_localmods *gossmods_from_listpeerchannels_(const tal_t *ctx,
u32, \
u32, \
bool, \
bool, \
const char *, \
const jsmntok_t *), \
(cbarg))
Expand All @@ -74,7 +72,6 @@ void gossmod_add_localchan(struct gossmap_localmods *mods,
u32 fee_proportional,
u32 cltv_delta,
bool enabled,
bool is_local,
const char *buf UNUSED,
const jsmntok_t *chantok UNUSED,
void *cbarg UNUSED);
Expand Down
7 changes: 3 additions & 4 deletions plugins/renepay/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,19 +465,18 @@ static void gossmod_cb(struct gossmap_localmods *mods,
u32 fee_proportional,
u32 cltv_delta,
bool enabled,
bool is_local,
const char *buf,
const jsmntok_t *chantok,
struct payment *payment)
{
struct amount_msat min, max;

if (is_local) {
/* local channels can send up to what's spendable */
if (scidd->dir == node_id_idx(self, peer)) {
/* our side of the channel can send up to what's spendable */
min = AMOUNT_MSAT(0);
max = spendable;
} else {
/* remote channels can send up no more than spendable */
/* the remote side can send up to no more than spendable */
min = htlcmin;
max = amount_msat_min(spendable, htlcmax);
}
Expand Down
2 changes: 0 additions & 2 deletions plugins/test/run-route-calc.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ void gossmod_add_localchan(struct gossmap_localmods *mods UNNEEDED,
u32 fee_proportional UNNEEDED,
u32 cltv_delta UNNEEDED,
bool enabled UNNEEDED,
bool is_local UNNEEDED,
const char *buf UNUSED UNNEEDED,
const jsmntok_t *chantok UNUSED UNNEEDED,
void *cbarg UNUSED UNNEEDED)
Expand All @@ -71,7 +70,6 @@ struct gossmap_localmods *gossmods_from_listpeerchannels_(const tal_t *ctx UNNEE
u32 fee_proportional UNNEEDED,
u32 cltv_delta UNNEEDED,
bool enabled UNNEEDED,
bool is_local UNNEEDED,
const char *buf_ UNNEEDED,
const jsmntok_t *chantok UNNEEDED,
void *cbarg_) UNNEEDED,
Expand Down
2 changes: 0 additions & 2 deletions plugins/test/run-route-overlong.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ void gossmod_add_localchan(struct gossmap_localmods *mods UNNEEDED,
u32 fee_proportional UNNEEDED,
u32 cltv_delta UNNEEDED,
bool enabled UNNEEDED,
bool is_local UNNEEDED,
const char *buf UNUSED UNNEEDED,
const jsmntok_t *chantok UNUSED UNNEEDED,
void *cbarg UNUSED UNNEEDED)
Expand All @@ -68,7 +67,6 @@ struct gossmap_localmods *gossmods_from_listpeerchannels_(const tal_t *ctx UNNEE
u32 fee_proportional UNNEEDED,
u32 cltv_delta UNNEEDED,
bool enabled UNNEEDED,
bool is_local UNNEEDED,
const char *buf_ UNNEEDED,
const jsmntok_t *chantok UNNEEDED,
void *cbarg_) UNNEEDED,
Expand Down
3 changes: 1 addition & 2 deletions plugins/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ static void gossmod_add_unknown_localchan(struct gossmap_localmods *mods,
u32 fee_proportional,
u32 cltv_delta,
bool enabled,
bool is_local,
const char *buf UNUSED,
const jsmntok_t *chantok UNUSED,
struct gossmap *gossmap)
Expand All @@ -379,7 +378,7 @@ static void gossmod_add_unknown_localchan(struct gossmap_localmods *mods,

gossmod_add_localchan(mods, self, peer, scidd, min, max, spendable,
fee_base, fee_proportional, cltv_delta, enabled,
is_local, buf, chantok, gossmap);
buf, chantok, gossmap);
}

/* FIXME: We don't need this listpeerchannels at all if not deprecated! */
Expand Down

0 comments on commit e5c705f

Please sign in to comment.