Browse Source

lightningd: move "tell gossipd peer is no longer important" to drop_to_chain.

Reported-by: @ZmnSCPxj
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
435e85a5b2
  1. 5
      lightningd/channel.c
  2. 4
      lightningd/closing_control.c
  3. 6
      lightningd/peer_control.c

5
lightningd/channel.c

@ -324,7 +324,6 @@ void channel_fail_permanent(struct channel *channel, const char *fmt, ...)
va_list ap;
char *why;
struct channel_id cid;
u8 *msg;
va_start(ap, fmt);
why = tal_vfmt(channel, fmt, ap);
@ -349,10 +348,6 @@ void channel_fail_permanent(struct channel *channel, const char *fmt, ...)
channel->error = towire_errorfmt(channel, &cid, "%s", why);
}
/* Tell gossipd we no longer need to keep connection to this peer */
msg = towire_gossipctl_peer_important(NULL, &channel->peer->id, false);
subd_send_msg(ld->gossip, take(msg));
channel_set_owner(channel, NULL);
/* Drop non-cooperatively (unilateral) to chain. */
drop_to_chain(ld, channel, false);

4
lightningd/closing_control.c

@ -96,10 +96,6 @@ static void peer_closing_complete(struct channel *channel, const u8 *msg)
if (channel->state == CLOSINGD_COMPLETE)
return;
/* Tell gossipd we no longer need to keep connection to this peer */
msg = towire_gossipctl_peer_important(NULL, &channel->peer->id, false);
subd_send_msg(channel->peer->ld->gossip, take(msg));
/* Channel gets dropped to chain cooperatively. */
drop_to_chain(channel->peer->ld, channel, true);
channel_set_state(channel, CLOSINGD_SIGEXCHANGE, CLOSINGD_COMPLETE);

6
lightningd/peer_control.c

@ -332,6 +332,12 @@ register_close_command(struct lightningd *ld,
void drop_to_chain(struct lightningd *ld, struct channel *channel,
bool cooperative)
{
u8 *msg;
/* Tell gossipd we no longer need to keep connection to this peer */
msg = towire_gossipctl_peer_important(NULL, &channel->peer->id, false);
subd_send_msg(ld->gossip, take(msg));
sign_last_tx(channel);
/* Keep broadcasting until we say stop (can fail due to dup,

Loading…
Cancel
Save