From 61317859f82891caac0fc6e0e38cee8b3cf39e2c Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sun, 29 Apr 2018 16:12:23 +0200 Subject: [PATCH] master: Move the gossipd initialization after the other inits If we start accepting peer connections before we initialized some of the other parts (mainly the chaintopology) we could end up asking for stuff that isn't ready yet (blockchain head for example). Signed-off-by: Christian Decker --- lightningd/lightningd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 429b20807..625620131 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -328,9 +328,6 @@ int main(int argc, char *argv[]) /* Now we know our ID, we can set our color/alias if not already. */ setup_color_and_alias(ld); - /* Set up gossip daemon. */ - gossip_init(ld); - /* Everything is within a transaction. */ db_begin_transaction(ld->wallet->db); @@ -394,6 +391,10 @@ int main(int argc, char *argv[]) ld->config.poll_time, blockheight); + /* Set up gossip daemon. Needs to be after the initialization of + * chaintopology, otherwise we may be asking for uninitialized data. */ + gossip_init(ld); + /* Replay transactions for all running onchainds */ onchaind_replay_channels(ld);