mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
lightningd: don't assume a single channel per peer.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
ba1242af3e
commit
f85425d106
2 changed files with 20 additions and 7 deletions
|
@ -99,14 +99,25 @@ routehint_candidates(const tal_t *ctx,
|
|||
if (!peer) {
|
||||
log_debug(ld->log, "%s: unknown peer",
|
||||
type_to_string(tmpctx,
|
||||
struct short_channel_id,
|
||||
&r->short_channel_id));
|
||||
struct node_id,
|
||||
&r->pubkey));
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Does it have a channel in state CHANNELD_NORMAL */
|
||||
candidate.c = peer_normal_channel(peer);
|
||||
/* Check channel is in CHANNELD_NORMAL */
|
||||
candidate.c = find_channel_by_scid(peer, &r->short_channel_id);
|
||||
if (!candidate.c) {
|
||||
log_debug(ld->log, "%s: channel not found in peer %s",
|
||||
type_to_string(tmpctx,
|
||||
struct short_channel_id,
|
||||
&r->short_channel_id),
|
||||
type_to_string(tmpctx,
|
||||
struct node_id,
|
||||
&r->pubkey));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (candidate.c->state != CHANNELD_NORMAL) {
|
||||
log_debug(ld->log, "%s: abnormal channel",
|
||||
type_to_string(tmpctx,
|
||||
struct short_channel_id,
|
||||
|
@ -120,6 +131,7 @@ routehint_candidates(const tal_t *ctx,
|
|||
* capacity ceiling. We *could* do multiple HTLCs,
|
||||
* but presumably that would defeat the spirit of the
|
||||
* limit anyway */
|
||||
/* FIXME: Present max capacity of multiple channels? */
|
||||
candidate.capacity = channel_amount_receivable(candidate.c);
|
||||
if (amount_msat_greater(candidate.capacity, htlc_max))
|
||||
candidate.capacity = htlc_max;
|
||||
|
|
|
@ -191,6 +191,10 @@ u8 *featurebits_or(const tal_t *ctx UNNEEDED, const u8 *f1 TAKES UNNEEDED, const
|
|||
struct channel *find_channel_by_id(const struct peer *peer UNNEEDED,
|
||||
const struct channel_id *cid UNNEEDED)
|
||||
{ fprintf(stderr, "find_channel_by_id called!\n"); abort(); }
|
||||
/* Generated stub for find_channel_by_scid */
|
||||
struct channel *find_channel_by_scid(const struct peer *peer UNNEEDED,
|
||||
const struct short_channel_id *scid UNNEEDED)
|
||||
{ fprintf(stderr, "find_channel_by_scid called!\n"); abort(); }
|
||||
/* Generated stub for find_plugin_for_command */
|
||||
struct plugin *find_plugin_for_command(struct lightningd *ld UNNEEDED,
|
||||
const char *cmd_name UNNEEDED)
|
||||
|
@ -585,9 +589,6 @@ struct command_result *param_u64(struct command *cmd UNNEEDED, const char *name
|
|||
/* Generated stub for peer_active_channel */
|
||||
struct channel *peer_active_channel(struct peer *peer UNNEEDED)
|
||||
{ fprintf(stderr, "peer_active_channel called!\n"); abort(); }
|
||||
/* Generated stub for peer_normal_channel */
|
||||
struct channel *peer_normal_channel(struct peer *peer UNNEEDED)
|
||||
{ fprintf(stderr, "peer_normal_channel called!\n"); abort(); }
|
||||
/* Generated stub for peer_restart_dualopend */
|
||||
void peer_restart_dualopend(struct peer *peer UNNEEDED,
|
||||
struct peer_fd *peer_fd UNNEEDED,
|
||||
|
|
Loading…
Add table
Reference in a new issue