From 16e16a725e7d1c67bbe1a3f04a2a38a5c7062cf2 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 24 Sep 2018 13:58:27 +0930 Subject: [PATCH] gossipd: apply private updates to announce channel. We trade channel_update before channel_announce makes the channel public, and currently forget them when we finally get the channel_announce. We should instead apply them, and not rely on retransmission (which we remove in the next patch!). This earlier channel_update means test_gossip_jsonrpc triggers too early, so have that wait for node_announcement. Signed-off-by: Rusty Russell --- gossipd/routing.c | 15 ++++++++++----- tests/test_gossip.py | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gossipd/routing.c b/gossipd/routing.c index f60384a2c..793357db4 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -753,11 +753,16 @@ bool routing_add_channel_announcement(struct routing_state *rstate, /* Channel is now public. */ chan->channel_announce = tal_dup_arr(chan, u8, msg, tal_count(msg), 0); - /* Clear any private updates: new updates will trigger broadcast of - * this channel_announce. */ - for (size_t i = 0; i < ARRAY_SIZE(chan->half); i++) - chan->half[i].channel_update - = tal_free(chan->half[i].channel_update); + /* Apply any private updates. */ + for (size_t i = 0; i < ARRAY_SIZE(chan->half); i++) { + const u8 *update = chan->half[i].channel_update; + if (!update) + continue; + + /* Remove from channel, otherwise it will be freed! */ + chan->half[i].channel_update = NULL; + routing_add_channel_update(rstate, take(update)); + } return true; } diff --git a/tests/test_gossip.py b/tests/test_gossip.py index 12287a858..d3e534cc0 100644 --- a/tests/test_gossip.py +++ b/tests/test_gossip.py @@ -282,7 +282,7 @@ def test_gossip_jsonrpc(node_factory): 'peer_in WIRE_ANNOUNCEMENT_SIGNATURES']) # Just wait for the update to kick off and then check the effect - needle = "Received channel_update for channel" + needle = "Received node_announcement for node" l1.daemon.wait_for_log(needle) l2.daemon.wait_for_log(needle) # Need to increase timeout, intervals cannot be shortened with DEVELOPER=0