mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-21 23:04:22 +01:00
plugins/pay: simplify listpeers_done code a little.
Avoid the unnecessary extra var, and don't use "capacity" since that usually refers to static capacity. Reported-by: @cdecker Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
a393272ebf
commit
4122f955c1
@@ -694,8 +694,8 @@ static struct command_result *listpeers_done(struct command *cmd,
|
||||
chan = json_get_member(buf, peer, "channels");
|
||||
chans_end = json_next(chan);
|
||||
for (chan = chan + 1; chan < chans_end; chan = json_next(chan)) {
|
||||
const jsmntok_t *state, *spendable, *scid, *dir;
|
||||
u64 capacity;
|
||||
const jsmntok_t *state, *scid, *dir;
|
||||
u64 spendable;
|
||||
|
||||
/* gossipd will only consider things in state NORMAL
|
||||
* anyway; we don't need to exclude others. */
|
||||
@@ -703,11 +703,12 @@ static struct command_result *listpeers_done(struct command *cmd,
|
||||
if (!json_tok_streq(buf, state, "CHANNELD_NORMAL"))
|
||||
continue;
|
||||
|
||||
spendable = json_get_member(buf, chan,
|
||||
"spendable_msatoshi");
|
||||
json_to_u64(buf, spendable, &capacity);
|
||||
json_to_u64(buf,
|
||||
json_get_member(buf, chan,
|
||||
"spendable_msatoshi"),
|
||||
&spendable);
|
||||
|
||||
if (connected && capacity >= pc->msatoshi)
|
||||
if (connected && spendable >= pc->msatoshi)
|
||||
continue;
|
||||
|
||||
/* Exclude this disconnected or low-capacity channel */
|
||||
@@ -722,7 +723,7 @@ static struct command_result *listpeers_done(struct command *cmd,
|
||||
tal_append_fmt(&mods,
|
||||
"Excluded channel %s (%"PRIu64" msat, %s). ",
|
||||
pc->excludes[tal_count(pc->excludes)-1],
|
||||
capacity,
|
||||
spendable,
|
||||
connected ? "connected" : "disconnected");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user