mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
lightningd: tell gossipd when we kill an opening channel.
And unify the code paths. Without this, a reconnect during opening might hang. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
f747ad8f73
commit
8e3bc84634
@ -128,6 +128,16 @@ static void uncommitted_channel_to_gossipd(struct lightningd *ld,
|
|||||||
subd_send_fd(ld->gossip, gossip_fd);
|
subd_send_fd(ld->gossip, gossip_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void uncommitted_channel_disconnect(struct uncommitted_channel *uc,
|
||||||
|
const char *desc)
|
||||||
|
{
|
||||||
|
u8 *msg = towire_gossipctl_peer_disconnected(tmpctx, &uc->peer->id);
|
||||||
|
log_info(uc->log, "%s", desc);
|
||||||
|
subd_send_msg(uc->peer->ld->gossip, msg);
|
||||||
|
if (uc->fc)
|
||||||
|
command_fail(uc->fc->cmd, LIGHTNINGD, "%s", desc);
|
||||||
|
}
|
||||||
|
|
||||||
void kill_uncommitted_channel(struct uncommitted_channel *uc,
|
void kill_uncommitted_channel(struct uncommitted_channel *uc,
|
||||||
const char *why)
|
const char *why)
|
||||||
{
|
{
|
||||||
@ -137,8 +147,7 @@ void kill_uncommitted_channel(struct uncommitted_channel *uc,
|
|||||||
subd_release_channel(uc->openingd, uc);
|
subd_release_channel(uc->openingd, uc);
|
||||||
uc->openingd = NULL;
|
uc->openingd = NULL;
|
||||||
|
|
||||||
if (uc->fc)
|
uncommitted_channel_disconnect(uc, why);
|
||||||
command_fail(uc->fc->cmd, LIGHTNINGD, "%s", why);
|
|
||||||
tal_free(uc);
|
tal_free(uc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,11 +552,7 @@ static void opening_channel_errmsg(struct uncommitted_channel *uc,
|
|||||||
const u8 *err_for_them)
|
const u8 *err_for_them)
|
||||||
{
|
{
|
||||||
if (peer_fd == -1) {
|
if (peer_fd == -1) {
|
||||||
u8 *msg = towire_gossipctl_peer_disconnected(tmpctx, &uc->peer->id);
|
uncommitted_channel_disconnect(uc, desc);
|
||||||
log_info(uc->log, "%s", desc);
|
|
||||||
subd_send_msg(uc->peer->ld->gossip, msg);
|
|
||||||
if (uc->fc)
|
|
||||||
command_fail(uc->fc->cmd, LIGHTNINGD, "%s", desc);
|
|
||||||
} else {
|
} else {
|
||||||
/* An error occurred (presumably negotiation fail). */
|
/* An error occurred (presumably negotiation fail). */
|
||||||
const char *errsrc = err_for_them ? "sent" : "received";
|
const char *errsrc = err_for_them ? "sent" : "received";
|
||||||
|
Loading…
Reference in New Issue
Block a user