Browse Source

peer_failed: write error message to peer directly.

We currently hand the error back to the master, who then stores it for
future connections and hands it back to another openingd to send and exit.

Just send directly; it's more reliable and simpler.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 6 years ago
committed by Christian Decker
parent
commit
b4e6a0fcad
  1. 11
      common/peer_failed.c
  2. 3
      lightningd/peer_control.c

11
common/peer_failed.c

@ -1,4 +1,5 @@
#include <ccan/tal/str/str.h>
#include <common/crypto_sync.h>
#include <common/gen_peer_status_wire.h>
#include <common/gen_status_wire.h>
#include <common/peer_billboard.h>
@ -15,16 +16,20 @@ void peer_failed_(int peer_fd, int gossip_fd,
{
va_list ap;
const char *desc;
u8 *msg;
u8 *msg, *err;
va_start(ap, fmt);
desc = tal_vfmt(NULL, fmt, ap);
va_end(ap);
/* Tell peer the error. */
err = towire_errorfmt(desc, channel_id, "%s", desc);
sync_crypto_write(cs, peer_fd, err);
/* Tell master the error so it can re-xmit. */
msg = towire_status_peer_error(NULL, channel_id,
desc, cs,
towire_errorfmt(desc, channel_id,
"%s", desc));
err);
peer_billboard(true, desc);
tal_free(desc);
status_send_fatal(take(msg), peer_fd, gossip_fd);

3
lightningd/peer_control.c

@ -418,9 +418,6 @@ void channel_errmsg(struct channel *channel,
channel_fail_permanent(channel, "%s: %s ERROR %s",
channel->owner->name,
err_for_them ? "sent" : "received", desc);
/* Get openingd to chat with them, maybe sending error. */
peer_start_openingd(channel->peer, cs, peer_fd, gossip_fd, err_for_them);
}
/* Connectd tells us a peer has connected: it never hands us duplicates, since

Loading…
Cancel
Save