mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-23 15:04:19 +01:00
gossipd: don't send gossip stream, let per-peer daemons read it themselves.
Keeping the uintmap ordering all the broadcastable messages is expensive: 130MB for the million-channels project. But now we delete obsolete entries from the store, we can have the per-peer daemons simply read that sequentially and stream the gossip itself. This is the most primitive version, where all gossip is streamed; successive patches will bring back proper handling of timestamp filtering and initial_routing_sync. We add a gossip_state field to track what's happening with our gossip streaming: it's initialized in gossipd, and currently always set, but once we handle timestamps the per-peer daemon may do it when the first filter is sent. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -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_msec,
|
||||
tmpctx,
|
||||
&get_chainparams(ld)->genesis_blockhash, &ld->id,
|
||||
get_offered_globalfeatures(tmpctx),
|
||||
ld->rgb,
|
||||
|
||||
@@ -801,18 +801,22 @@ void peer_connected(struct lightningd *ld, const u8 *msg,
|
||||
u8 *globalfeatures, *localfeatures;
|
||||
struct peer *peer;
|
||||
struct peer_connected_hook_payload *hook_payload;
|
||||
struct crypto_state cs;
|
||||
|
||||
hook_payload = tal(NULL, struct peer_connected_hook_payload);
|
||||
hook_payload->ld = ld;
|
||||
if (!fromwire_connect_peer_connected(msg, msg,
|
||||
if (!fromwire_connect_peer_connected(hook_payload, msg,
|
||||
&id, &hook_payload->addr,
|
||||
&cs,
|
||||
&hook_payload->pps,
|
||||
&globalfeatures, &localfeatures))
|
||||
fatal("Connectd gave bad CONNECT_PEER_CONNECTED message %s",
|
||||
tal_hex(msg, msg));
|
||||
|
||||
hook_payload->pps = new_per_peer_state(hook_payload, &cs);
|
||||
#if DEVELOPER
|
||||
/* Override broaedcast interval from our config */
|
||||
hook_payload->pps->dev_gossip_broadcast_msec
|
||||
= ld->config.broadcast_interval_msec;
|
||||
#endif
|
||||
|
||||
per_peer_state_set_fds(hook_payload->pps,
|
||||
peer_fd, gossip_fd, gossip_store_fd);
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ void fatal(const char *fmt UNNEEDED, ...)
|
||||
bool fromwire_channel_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_channel_dev_memleak_reply called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_connect_peer_connected */
|
||||
bool fromwire_connect_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, struct crypto_state *cs UNNEEDED, u8 **globalfeatures UNNEEDED, u8 **localfeatures UNNEEDED)
|
||||
bool fromwire_connect_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **globalfeatures UNNEEDED, u8 **localfeatures UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_connect_peer_connected called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_gossip_get_incoming_channels_reply */
|
||||
bool fromwire_gossip_get_incoming_channels_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct route_info **route_info UNNEEDED)
|
||||
@@ -260,10 +260,6 @@ struct log *new_log(const tal_t *ctx UNNEEDED, struct log_book *record UNNEEDED,
|
||||
struct log_book *new_log_book(size_t max_mem UNNEEDED,
|
||||
enum log_level printlevel UNNEEDED)
|
||||
{ fprintf(stderr, "new_log_book called!\n"); abort(); }
|
||||
/* Generated stub for new_per_peer_state */
|
||||
struct per_peer_state *new_per_peer_state(const tal_t *ctx UNNEEDED,
|
||||
const struct crypto_state *cs UNNEEDED)
|
||||
{ fprintf(stderr, "new_per_peer_state called!\n"); abort(); }
|
||||
/* Generated stub for new_reltimer_ */
|
||||
struct oneshot *new_reltimer_(struct timers *timers UNNEEDED,
|
||||
const tal_t *ctx UNNEEDED,
|
||||
|
||||
Reference in New Issue
Block a user