Skip to content

Commit

Permalink
gossipd: don't initialize broadcast interval, make field name explicit.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rustyrussell committed Oct 15, 2018
1 parent 3991425 commit afac013
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gossipd/gossip_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions gossipd/gossipd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion lightningd/gossip_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lightningd/lightningd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ static void dev_register_opts(struct lightningd *ld)
opt_register_arg("--dev-debugger=<subdaemon>", opt_subd_debug, NULL,
ld, "Invoke gdb at start of <subdaemon>");
opt_register_arg("--dev-broadcast-interval=<ms>", 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=<filename>", opt_subd_dev_disconnect,
NULL, ld, "File containing disconnection points");
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit afac013

Please sign in to comment.