From 178baeba6c9de14224c501a7d42d3de8060880d6 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 16 Sep 2019 14:42:15 +0930 Subject: [PATCH] gossipd: get gossip_min_interval from lightningd. Default is 5 x gossip interval == 5 minutes. Signed-off-by: Rusty Russell --- gossipd/gossip_wire.csv | 1 + gossipd/gossipd.c | 6 ++++++ gossipd/test/run-crc32_of_update.c | 5 +---- gossipd/test/run-extended-info.c | 5 +---- lightningd/gossip_control.c | 2 ++ 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/gossipd/gossip_wire.csv b/gossipd/gossip_wire.csv index 0e300e18d..304ecb192 100644 --- a/gossipd/gossip_wire.csv +++ b/gossipd/gossip_wire.csv @@ -11,6 +11,7 @@ msgdata,gossipctl_init,globalfeatures,u8,gflen msgdata,gossipctl_init,rgb,u8,3 msgdata,gossipctl_init,alias,u8,32 msgdata,gossipctl_init,update_channel_interval,u32, +msgdata,gossipctl_init,gossip_min_interval,u32, msgdata,gossipctl_init,num_announcable,u16, msgdata,gossipctl_init,announcable,wireaddr,num_announcable msgdata,gossipctl_init,dev_gossip_time,?u32, diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index af72a68bd..cab92c54e 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -133,6 +133,9 @@ struct daemon { /* Timers: we batch gossip, and also refresh announcements */ struct timers timers; + /* Minimum interval for generating updated gossip */ + u32 gossip_min_interval; + /* Global features to list in node_announcement. */ u8 *globalfeatures; @@ -2475,6 +2478,9 @@ static struct io_plan *gossip_init(struct io_conn *conn, /* 1 week in seconds * (unless --dev-channel-update-interval) */ &update_channel_interval, + /* 5 minutes, or + * --dev-broadcast-interval * 5 seconds */ + &daemon->gossip_min_interval, &daemon->announcable, &dev_gossip_time)) { master_badmsg(WIRE_GOSSIPCTL_INIT, msg); diff --git a/gossipd/test/run-crc32_of_update.c b/gossipd/test/run-crc32_of_update.c index 07bd7ec37..3bd067666 100644 --- a/gossipd/test/run-crc32_of_update.c +++ b/gossipd/test/run-crc32_of_update.c @@ -54,7 +54,7 @@ bool fromwire_expiry_too_soon(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, bool fromwire_fee_insufficient(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct amount_msat *htlc_msat UNNEEDED, u8 **channel_update UNNEEDED) { fprintf(stderr, "fromwire_fee_insufficient called!\n"); abort(); } /* Generated stub for fromwire_gossipctl_init */ -bool fromwire_gossipctl_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct node_id *id UNNEEDED, u8 **globalfeatures UNNEEDED, u8 rgb[3] UNNEEDED, u8 alias[32] UNNEEDED, u32 *update_channel_interval UNNEEDED, struct wireaddr **announcable UNNEEDED, u32 **dev_gossip_time UNNEEDED) +bool fromwire_gossipctl_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct node_id *id UNNEEDED, u8 **globalfeatures UNNEEDED, u8 rgb[3] UNNEEDED, u8 alias[32] UNNEEDED, u32 *update_channel_interval UNNEEDED, u32 *gossip_min_interval UNNEEDED, struct wireaddr **announcable UNNEEDED, u32 **dev_gossip_time UNNEEDED) { fprintf(stderr, "fromwire_gossipctl_init called!\n"); abort(); } /* Generated stub for fromwire_gossip_dev_set_max_scids_encode_size */ bool fromwire_gossip_dev_set_max_scids_encode_size(const void *p UNNEEDED, u32 *max UNNEEDED) @@ -317,9 +317,6 @@ u8 *towire_hsm_node_announcement_sig_req(const tal_t *ctx UNNEEDED, const u8 *an /* Generated stub for towire_wireaddr */ void towire_wireaddr(u8 **pptr UNNEEDED, const struct wireaddr *addr UNNEEDED) { fprintf(stderr, "towire_wireaddr called!\n"); abort(); } -/* Generated stub for wireaddr_eq */ -bool wireaddr_eq(const struct wireaddr *a UNNEEDED, const struct wireaddr *b UNNEEDED) -{ fprintf(stderr, "wireaddr_eq called!\n"); abort(); } /* Generated stub for wire_sync_read */ u8 *wire_sync_read(const tal_t *ctx UNNEEDED, int fd UNNEEDED) { fprintf(stderr, "wire_sync_read called!\n"); abort(); } diff --git a/gossipd/test/run-extended-info.c b/gossipd/test/run-extended-info.c index e06fb3dd1..65a7d661b 100644 --- a/gossipd/test/run-extended-info.c +++ b/gossipd/test/run-extended-info.c @@ -77,7 +77,7 @@ bool fromwire_expiry_too_soon(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, bool fromwire_fee_insufficient(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct amount_msat *htlc_msat UNNEEDED, u8 **channel_update UNNEEDED) { fprintf(stderr, "fromwire_fee_insufficient called!\n"); abort(); } /* Generated stub for fromwire_gossipctl_init */ -bool fromwire_gossipctl_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct node_id *id UNNEEDED, u8 **globalfeatures UNNEEDED, u8 rgb[3] UNNEEDED, u8 alias[32] UNNEEDED, u32 *update_channel_interval UNNEEDED, struct wireaddr **announcable UNNEEDED, u32 **dev_gossip_time UNNEEDED) +bool fromwire_gossipctl_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct node_id *id UNNEEDED, u8 **globalfeatures UNNEEDED, u8 rgb[3] UNNEEDED, u8 alias[32] UNNEEDED, u32 *update_channel_interval UNNEEDED, u32 *gossip_min_interval UNNEEDED, struct wireaddr **announcable UNNEEDED, u32 **dev_gossip_time UNNEEDED) { fprintf(stderr, "fromwire_gossipctl_init called!\n"); abort(); } /* Generated stub for fromwire_gossip_dev_set_max_scids_encode_size */ bool fromwire_gossip_dev_set_max_scids_encode_size(const void *p UNNEEDED, u32 *max UNNEEDED) @@ -336,9 +336,6 @@ u8 *towire_hsm_node_announcement_sig_req(const tal_t *ctx UNNEEDED, const u8 *an /* Generated stub for towire_wireaddr */ void towire_wireaddr(u8 **pptr UNNEEDED, const struct wireaddr *addr UNNEEDED) { fprintf(stderr, "towire_wireaddr called!\n"); abort(); } -/* Generated stub for wireaddr_eq */ -bool wireaddr_eq(const struct wireaddr *a UNNEEDED, const struct wireaddr *b UNNEEDED) -{ fprintf(stderr, "wireaddr_eq called!\n"); abort(); } /* Generated stub for wire_sync_read */ u8 *wire_sync_read(const tal_t *ctx UNNEEDED, int fd UNNEEDED) { fprintf(stderr, "wire_sync_read called!\n"); abort(); } diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 6da7b3c29..4be87789e 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -196,6 +196,8 @@ void gossip_init(struct lightningd *ld, int connectd_fd) get_offered_globalfeatures(tmpctx), ld->rgb, ld->alias, ld->config.channel_update_interval, + /* gossip_min_interval: 5x the broadcast interval */ + ld->config.broadcast_interval_msec / 200, ld->announcable, IFDEV(ld->dev_gossip_time ? &ld->dev_gossip_time: NULL, NULL)); subd_send_msg(ld->gossip, msg);