From ffddb91e3e69827fca2a6ceaa9d6a7e0a59510bc Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 22 Aug 2017 14:36:37 +0930 Subject: [PATCH] gossipd: hand in chain_hash. This will be needed for gossip messages. Signed-off-by: Rusty Russell --- lightningd/gossip/gossip.c | 21 ++++++++++++--------- lightningd/gossip/gossip_wire.csv | 1 + lightningd/gossip_control.c | 3 ++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lightningd/gossip/gossip.c b/lightningd/gossip/gossip.c index de067d0dd..ae3cb0a87 100644 --- a/lightningd/gossip/gossip.c +++ b/lightningd/gossip/gossip.c @@ -653,10 +653,21 @@ static struct io_plan *ping_req(struct io_conn *conn, struct daemon *daemon, static struct io_plan *gossip_init(struct daemon_conn *master, struct daemon *daemon, u8 *msg) { - if (!fromwire_gossipctl_init(msg, NULL, &daemon->broadcast_interval)) { + struct sha256_double chain_hash; + struct log_book *log_book; + struct log *base_log; + + if (!fromwire_gossipctl_init(msg, NULL, &daemon->broadcast_interval, + &chain_hash)) { status_failed(WIRE_GOSSIPSTATUS_INIT_FAILED, "Unable to parse init message"); } + /* Do not log absolutely anything, stdout is now a socket + * connected to some other daemon. */ + log_book = new_log_book(daemon, 2 * 1024 * 1024, LOG_BROKEN + 1); + base_log = + new_log(daemon, log_book, "lightningd_gossip(%u):", (int)getpid()); + daemon->rstate = new_routing_state(daemon, base_log); return daemon_conn_read_next(master->conn, master); } @@ -773,8 +784,6 @@ static void master_gone(struct io_conn *unused, struct daemon_conn *dc) int main(int argc, char *argv[]) { struct daemon *daemon; - struct log_book *log_book; - struct log *base_log; subdaemon_debug(argc, argv); @@ -787,12 +796,6 @@ int main(int argc, char *argv[]) SECP256K1_CONTEXT_SIGN); daemon = tal(NULL, struct daemon); - /* Do not log absolutely anything, stdout is now a socket - * connected to some other daemon. */ - log_book = new_log_book(daemon, 2 * 1024 * 1024, LOG_BROKEN + 1); - base_log = - new_log(daemon, log_book, "lightningd_gossip(%u):", (int)getpid()); - daemon->rstate = new_routing_state(daemon, base_log); list_head_init(&daemon->peers); timers_init(&daemon->timers, time_mono()); daemon->broadcast_interval = 30000; diff --git a/lightningd/gossip/gossip_wire.csv b/lightningd/gossip/gossip_wire.csv index 51a7baca4..f12602cf9 100644 --- a/lightningd/gossip/gossip_wire.csv +++ b/lightningd/gossip/gossip_wire.csv @@ -23,6 +23,7 @@ gossipstatus_peer_failed,,err,len*u8 # Initialize the gossip daemon gossipctl_init,0 gossipctl_init,,broadcast_interval,4 +gossipctl_init,,chain_hash,struct sha256_double # These take an fd, but have no response # (if it is to move onto a channel, we get a status msg). diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index f26877311..166d29230 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -149,7 +149,8 @@ void gossip_init(struct lightningd *ld) if (!ld->gossip) err(1, "Could not subdaemon gossip"); - init = towire_gossipctl_init(tmpctx, ld->broadcast_interval); + init = towire_gossipctl_init(tmpctx, ld->broadcast_interval, + &ld->chainparams->genesis_blockhash); subd_send_msg(ld->gossip, init); tal_free(tmpctx); }