mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
cc9ca82821
Ideally we'd rename status_failed() to status_fatal(), but that's too much churn for now. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
34 lines
818 B
C
34 lines
818 B
C
#include <ccan/io/io.h>
|
|
#include <ccan/tal/str/str.h>
|
|
#include <common/crypto_sync.h>
|
|
#include <common/peer_failed.h>
|
|
#include <common/status.h>
|
|
#include <common/wire_error.h>
|
|
#include <fcntl.h>
|
|
#include <stdarg.h>
|
|
#include <unistd.h>
|
|
#include <wire/gen_peer_wire.h>
|
|
|
|
/* We only support one channel per peer anyway */
|
|
void peer_failed(int peer_fd, struct crypto_state *cs,
|
|
const struct channel_id *channel_id,
|
|
const char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
const char *desc;
|
|
u8 *msg;
|
|
|
|
va_start(ap, fmt);
|
|
desc = tal_vfmt(NULL, fmt, ap);
|
|
va_end(ap);
|
|
|
|
status_broken("SENT ERROR:%s", desc);
|
|
msg = towire_errorfmt(desc, channel_id, "%s", desc);
|
|
|
|
/* This is only best-effort; don't block. */
|
|
io_fd_block(peer_fd, false);
|
|
sync_crypto_write(cs, peer_fd, msg);
|
|
|
|
status_fatal_sent_errmsg(take(msg), desc, channel_id);
|
|
}
|