Browse Source

gossipd: hand in chain_hash.

This will be needed for gossip messages.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
ffddb91e3e
  1. 21
      lightningd/gossip/gossip.c
  2. 1
      lightningd/gossip/gossip_wire.csv
  3. 3
      lightningd/gossip_control.c

21
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;

1
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).

Can't render this file because it has a wrong number of fields in line 2.

3
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);
}

Loading…
Cancel
Save