From 1a5a4f58537633f85581c609ac911f5e2bc00899 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sun, 18 Mar 2018 15:05:33 +0100 Subject: [PATCH] gossip: Replay gossip messages from the gossip_store Signed-off-by: Christian Decker --- gossipd/gossip.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gossipd/gossip.c b/gossipd/gossip.c index b51f509e5..f7382a34d 100644 --- a/gossipd/gossip.c +++ b/gossipd/gossip.c @@ -1522,6 +1522,23 @@ static void setup_listeners(struct daemon *daemon, u16 portnum) portnum); } +/** + * Callback function to be called whenever the master connection is idle + */ +static bool master_conn_idle(struct io_conn *conn UNUSED, + struct daemon_conn *dc) +{ + const u8 *msg; + struct daemon *daemon = container_of(dc, struct daemon, master); + msg = gossip_store_read_next(tmpctx, daemon->rstate->store); + + if (msg) { + handle_gossip_msg(daemon, msg); + return true; + } else { + return false; + } +} /* Parse an incoming gossip init message and assign config variables * to the daemon. @@ -1545,6 +1562,8 @@ static struct io_plan *gossip_init(struct daemon_conn *master, daemon->rstate = new_routing_state(daemon, &chain_hash, &daemon->id, update_channel_interval * 2); + master->msg_queue_cleared_cb = master_conn_idle; + setup_listeners(daemon, port); new_reltimer(&daemon->timers, daemon,