From afac01380df77afc8994f084694c88dc5bc38345 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 15 Oct 2018 15:27:38 +1030 Subject: [PATCH] gossipd: don't initialize broadcast interval, make field name explicit. We initialize it to 30 seconds, but it's *always* overridden by the gossip_init message (and usually to 60 seconds, so it's doubly misleading). Signed-off-by: Rusty Russell --- gossipd/gossip_wire.csv | 2 +- gossipd/gossipd.c | 7 +++---- lightningd/gossip_control.c | 2 +- lightningd/lightningd.h | 2 +- lightningd/options.c | 6 +++--- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/gossipd/gossip_wire.csv b/gossipd/gossip_wire.csv index 6bfe07762..66f7f43bf 100644 --- a/gossipd/gossip_wire.csv +++ b/gossipd/gossip_wire.csv @@ -4,7 +4,7 @@ # Initialize the gossip daemon. gossipctl_init,3000 -gossipctl_init,,broadcast_interval,u32 +gossipctl_init,,broadcast_interval_msec,u32 gossipctl_init,,chain_hash,struct bitcoin_blkid gossipctl_init,,id,struct pubkey gossipctl_init,,gflen,u16 diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index b0da6e14a..3e6be87cf 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -80,7 +80,7 @@ struct daemon { struct timers timers; - u32 broadcast_interval; + u32 broadcast_interval_msec; /* Global features to list in node_announcement. */ u8 *globalfeatures; @@ -929,7 +929,7 @@ static bool maybe_queue_gossip(struct peer *peer) /* Gossip is drained. Wait for next timer. */ peer->gossip_timer = new_reltimer(&peer->daemon->timers, peer, - time_from_msec(peer->daemon->broadcast_interval), + time_from_msec(peer->daemon->broadcast_interval_msec), wake_gossip_out, peer); return false; } @@ -1818,7 +1818,7 @@ static struct io_plan *gossip_init(struct daemon_conn *master, u32 update_channel_interval; if (!fromwire_gossipctl_init( - daemon, msg, &daemon->broadcast_interval, &chain_hash, + daemon, msg, &daemon->broadcast_interval_msec, &chain_hash, &daemon->id, &daemon->globalfeatures, daemon->rgb, daemon->alias, &update_channel_interval, @@ -2140,7 +2140,6 @@ int main(int argc, char *argv[]) daemon = tal(NULL, struct daemon); list_head_init(&daemon->peers); timers_init(&daemon->timers, time_mono()); - daemon->broadcast_interval = 30000; daemon->last_announce_timestamp = 0; /* stdin == control */ diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index e31d5cbf9..23ae2c7c1 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -161,7 +161,7 @@ void gossip_init(struct lightningd *ld, int connectd_fd) err(1, "Could not subdaemon gossip"); msg = towire_gossipctl_init( - tmpctx, ld->config.broadcast_interval, + tmpctx, ld->config.broadcast_interval_msec, &get_chainparams(ld)->genesis_blockhash, &ld->id, get_offered_globalfeatures(tmpctx), ld->rgb, diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index bfc2b58a3..ff3bcff1f 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -46,7 +46,7 @@ struct config { u32 commit_time_ms; /* How often to broadcast gossip (msec) */ - u32 broadcast_interval; + u32 broadcast_interval_msec; /* Channel update interval */ u32 channel_update_interval; diff --git a/lightningd/options.c b/lightningd/options.c index d194d52d8..9172bde53 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -405,7 +405,7 @@ static void dev_register_opts(struct lightningd *ld) opt_register_arg("--dev-debugger=", opt_subd_debug, NULL, ld, "Invoke gdb at start of "); opt_register_arg("--dev-broadcast-interval=", opt_set_uintval, - opt_show_uintval, &ld->config.broadcast_interval, + opt_show_uintval, &ld->config.broadcast_interval_msec, "Time between gossip broadcasts in milliseconds"); opt_register_arg("--dev-disconnect=", opt_subd_dev_disconnect, NULL, ld, "File containing disconnection points"); @@ -465,7 +465,7 @@ static const struct config testnet_config = { * - SHOULD flush outgoing gossip messages once every 60 * seconds, independently of the arrival times of the messages. */ - .broadcast_interval = 60000, + .broadcast_interval_msec = 60000, /* Send a keepalive update at least every week, prune every twice that */ .channel_update_interval = 1209600/2, @@ -528,7 +528,7 @@ static const struct config mainnet_config = { * - SHOULD flush outgoing gossip messages once every 60 * seconds, independently of the arrival times of the messages. */ - .broadcast_interval = 60000, + .broadcast_interval_msec = 60000, /* Send a keepalive update at least every week, prune every twice that */ .channel_update_interval = 1209600/2,