From d4a172e22192916a85ffb80bce88585a199a27a5 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 23 Feb 2018 16:23:47 +1030 Subject: [PATCH] common: peer_billboard() helper for updating the billboard. Signed-off-by: Rusty Russell --- common/Makefile | 1 + common/peer_billboard.c | 17 +++++++++++++++++ common/peer_billboard.h | 9 +++++++++ common/status.c | 2 +- common/status.h | 1 + 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 common/peer_billboard.c create mode 100644 common/peer_billboard.h diff --git a/common/Makefile b/common/Makefile index 7245c8da3..368d55622 100644 --- a/common/Makefile +++ b/common/Makefile @@ -25,6 +25,7 @@ COMMON_SRC_NOGEN := \ common/keyset.c \ common/memleak.c \ common/msg_queue.c \ + common/peer_billboard.c \ common/peer_failed.c \ common/permute_tx.c \ common/ping.c \ diff --git a/common/peer_billboard.c b/common/peer_billboard.c new file mode 100644 index 000000000..29c4062af --- /dev/null +++ b/common/peer_billboard.c @@ -0,0 +1,17 @@ +#include +#include +#include +#include + +void peer_billboard(bool perm, const char *fmt, ...) +{ + va_list ap; + char *str; + + va_start(ap, fmt); + str = tal_vfmt(NULL, fmt, ap); + va_end(ap); + + status_send(take(towire_status_peer_billboard(NULL, perm, str))); + tal_free(str); +} diff --git a/common/peer_billboard.h b/common/peer_billboard.h new file mode 100644 index 000000000..0f558e580 --- /dev/null +++ b/common/peer_billboard.h @@ -0,0 +1,9 @@ +#ifndef LIGHTNING_COMMON_PEER_BILLBOARD_H +#define LIGHTNING_COMMON_PEER_BILLBOARD_H +#include "config.h" +#include + +/* Key information for RPC display: perm means it outlasts this daemon. */ +void peer_billboard(bool perm, const char *fmt, ...); + +#endif /* LIGHTNING_COMMON_PEER_BILLBOARD_H */ diff --git a/common/status.c b/common/status.c index 8a9cac251..640923945 100644 --- a/common/status.c +++ b/common/status.c @@ -57,7 +57,7 @@ void status_setup_async(struct daemon_conn *master) setup_logging_sighandler(); } -static void status_send(const u8 *msg TAKES) +void status_send(const u8 *msg TAKES) { if (status_fd >= 0) { int type =fromwire_peektype(msg); diff --git a/common/status.h b/common/status.h index 4a3f2e3ff..52718e574 100644 --- a/common/status.h +++ b/common/status.h @@ -51,5 +51,6 @@ void status_failed(enum status_failreason code, * msg NULL == read failure. */ void master_badmsg(u32 type_expected, const u8 *msg) NORETURN; +void status_send(const u8 *msg TAKES); void status_send_fatal(const u8 *msg TAKES, int fd1, int fd2) NORETURN; #endif /* LIGHTNING_COMMON_STATUS_H */