diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index 15bd4a46fee5..f82833b68097 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -1,11 +1,12 @@ /*~ Welcome to the gossip daemon: keeper of maps! * - * This is the last "global" daemon; it has three purposes. + * This is the last "global" daemon; it has one main purpose: to + * maintain the append-only gossip_store file for other daemons and + * plugins to read the global network map. * - * 1. To determine routes for payments when lightningd asks. - * 2. The second purpose is to receive gossip from peers (via their - * per-peer daemons) and send it out to them. - * 3. Talk to `connectd` to to answer address queries for nodes. + * To do this, it gets gossip messages forwarded from connectd, makes + * gossip queries to peers, and can ask connect out to random peers to + * get more gossip. * * The gossip protocol itself is fairly simple, but has some twists which * add complexity to this daemon. @@ -14,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -368,21 +368,6 @@ static void master_or_connectd_gone(struct daemon_conn *dc UNUSED) exit(2); } -/* We don't check this when loading from the gossip_store: that would break - * our canned tests, and usually old gossip is better than no gossip */ -bool timestamp_reasonable(const struct daemon *daemon, u32 timestamp) -{ - u64 now = clock_time().ts.tv_sec; - - /* More than one day ahead? */ - if (timestamp > now + 24*60*60) - return false; - /* More than 2 weeks behind? */ - if (timestamp < now - GOSSIP_PRUNE_INTERVAL(daemon->dev_fast_gossip_prune)) - return false; - return true; -} - /*~ Parse init message from lightningd: starts the daemon properly. */ static void gossip_init(struct daemon *daemon, const u8 *msg) { @@ -591,9 +576,6 @@ int main(int argc, char *argv[]) daemon->deferred_txouts = tal_arr(daemon, struct short_channel_id, 0); daemon->current_blockheight = 0; /* i.e. unknown */ - /* Tell the ecdh() function how to talk to hsmd */ - ecdh_hsmd_setup(HSM_FD, status_failed); - /* Note the use of time_mono() here. That's a monotonic clock, which * is really useful: it can only be used to measure relative events * (there's no correspondence to time-since-Ken-grew-a-beard or @@ -620,8 +602,9 @@ int main(int argc, char *argv[]) } } -/*~ Note that the actual routing stuff is in routing.c; you might want to - * check that out later. +/*~ Note that the production of the gossip_store file is in gossmap_manage.c + * and gossip_store.c, and the (highly optimized!) read side is in + * common/gossmap.c; you might want to check those out later. * * But that's the last of the global daemons. We now move on to the first of * the per-peer daemons: openingd/openingd.c. diff --git a/gossipd/gossipd.h b/gossipd/gossipd.h index d558f58f3a26..d8aa5447af30 100644 --- a/gossipd/gossipd.h +++ b/gossipd/gossipd.h @@ -8,11 +8,8 @@ #include #include -/* We talk to `hsmd` to sign our gossip messages with the node key */ -#define HSM_FD 3 -/* connectd asks us for help finding nodes, and gossip fds for new peers */ -#define CONNECTD_FD 4 -#define CONNECTD2_FD 5 +/* connectd forwards gossip messages to us. */ +#define CONNECTD_FD 3 struct chan; struct peer; @@ -161,9 +158,4 @@ void tell_lightningd_peer_update(struct daemon *daemon, struct amount_msat htlc_minimum, struct amount_msat htlc_maximum); -/** - * Is this gossip timestamp reasonable? - */ -bool timestamp_reasonable(const struct daemon *daemon, u32 timestamp); - #endif /* LIGHTNING_GOSSIPD_GOSSIPD_H */ diff --git a/gossipd/gossmap_manage.c b/gossipd/gossmap_manage.c index 3227465da5ae..9fd78a1f2803 100644 --- a/gossipd/gossmap_manage.c +++ b/gossipd/gossmap_manage.c @@ -893,6 +893,21 @@ static const char *process_channel_update(const tal_t *ctx, return NULL; } +/* We don't check this when loading from the gossip_store: that would break + * our canned tests, and usually old gossip is better than no gossip */ +static bool timestamp_reasonable(const struct daemon *daemon, u32 timestamp) +{ + u64 now = clock_time().ts.tv_sec; + + /* More than one day ahead? */ + if (timestamp > now + 24*60*60) + return false; + /* More than 2 weeks behind? */ + if (timestamp < now - GOSSIP_PRUNE_INTERVAL(daemon->dev_fast_gossip_prune)) + return false; + return true; +} + const char *gossmap_manage_channel_update(const tal_t *ctx, struct gossmap_manage *gm, const u8 *update TAKES, diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 7ecf0a531f7e..a43d967c7d1e 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -302,14 +302,11 @@ static void gossipd_init_done(struct subd *gossipd, void gossip_init(struct lightningd *ld, int connectd_fd) { u8 *msg; - int hsmfd; void *ret; - hsmfd = hsm_get_global_fd(ld, HSM_PERM_ECDH|HSM_PERM_SIGN_GOSSIP); - ld->gossip = new_global_subd(ld, "lightning_gossipd", gossipd_wire_name, gossip_msg, - take(&hsmfd), take(&connectd_fd), NULL); + take(&connectd_fd), NULL); if (!ld->gossip) err(1, "Could not subdaemon gossip");