gossipd: hand in chain_hash.

This will be needed for gossip messages.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-08-22 14:36:37 +09:30
committed by Christian Decker
parent 2b9d3bb0b7
commit ffddb91e3e
3 changed files with 15 additions and 10 deletions

View File

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

View File

@@ -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).
1 # These are fatal.
23 # (if it is to move onto a channel, we get a status msg). # These take an fd, but have no response
24 gossipctl_new_peer,1 # (if it is to move onto a channel, we get a status msg).
25 gossipctl_new_peer,,unique_id,8 gossipctl_new_peer,1
26 gossipctl_new_peer,,unique_id,8
27 gossipctl_new_peer,,crypto_state,struct crypto_state
28 # Tell it to release a peer which has initialized.
29 gossipctl_release_peer,2

View File

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