common: peer_billboard() helper for updating the billboard.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-02-23 16:23:47 +10:30 committed by Christian Decker
parent cca0a5412e
commit d4a172e221
5 changed files with 29 additions and 1 deletions

View File

@ -25,6 +25,7 @@ COMMON_SRC_NOGEN := \
common/keyset.c \ common/keyset.c \
common/memleak.c \ common/memleak.c \
common/msg_queue.c \ common/msg_queue.c \
common/peer_billboard.c \
common/peer_failed.c \ common/peer_failed.c \
common/permute_tx.c \ common/permute_tx.c \
common/ping.c \ common/ping.c \

17
common/peer_billboard.c Normal file
View File

@ -0,0 +1,17 @@
#include <ccan/tal/str/str.h>
#include <common/gen_status_wire.h>
#include <common/peer_billboard.h>
#include <common/status.h>
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);
}

9
common/peer_billboard.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef LIGHTNING_COMMON_PEER_BILLBOARD_H
#define LIGHTNING_COMMON_PEER_BILLBOARD_H
#include "config.h"
#include <stdbool.h>
/* 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 */

View File

@ -57,7 +57,7 @@ void status_setup_async(struct daemon_conn *master)
setup_logging_sighandler(); setup_logging_sighandler();
} }
static void status_send(const u8 *msg TAKES) void status_send(const u8 *msg TAKES)
{ {
if (status_fd >= 0) { if (status_fd >= 0) {
int type =fromwire_peektype(msg); int type =fromwire_peektype(msg);

View File

@ -51,5 +51,6 @@ void status_failed(enum status_failreason code,
* msg NULL == read failure. */ * msg NULL == read failure. */
void master_badmsg(u32 type_expected, const u8 *msg) NORETURN; 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; void status_send_fatal(const u8 *msg TAKES, int fd1, int fd2) NORETURN;
#endif /* LIGHTNING_COMMON_STATUS_H */ #endif /* LIGHTNING_COMMON_STATUS_H */