mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
gossipd: only broadcast channel_announcement once we have a channel_update.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
601a855543
commit
c2189229ca
2 changed files with 14 additions and 5 deletions
|
@ -635,10 +635,8 @@ bool routing_add_channel_announcement(struct routing_state *rstate,
|
|||
/* Channel is now public. */
|
||||
chan->channel_announce = tal_dup_arr(chan, u8, msg, tal_len(msg), 0);
|
||||
|
||||
/* Now we can broadcast channel announce */
|
||||
insert_broadcast(rstate->broadcasts, chan->channel_announce);
|
||||
|
||||
/* Clear any private updates. */
|
||||
/* 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);
|
||||
|
@ -934,6 +932,7 @@ bool routing_add_channel_update(struct routing_state *rstate,
|
|||
struct bitcoin_blkid chain_hash;
|
||||
struct chan *chan;
|
||||
u8 direction;
|
||||
bool have_broadcast_announce;
|
||||
|
||||
if (!fromwire_channel_update(update, &signature, &chain_hash,
|
||||
&short_channel_id, ×tamp, &flags,
|
||||
|
@ -944,6 +943,10 @@ bool routing_add_channel_update(struct routing_state *rstate,
|
|||
if (!chan)
|
||||
return false;
|
||||
|
||||
/* We broadcast announce once we have one update */
|
||||
have_broadcast_announce = is_halfchan_defined(&chan->half[0])
|
||||
|| is_halfchan_defined(&chan->half[1]);
|
||||
|
||||
direction = flags & 0x1;
|
||||
set_connection_values(chan, direction, fee_base_msat,
|
||||
fee_proportional_millionths, expiry,
|
||||
|
@ -959,6 +962,13 @@ bool routing_add_channel_update(struct routing_state *rstate,
|
|||
if (!chan->channel_announce)
|
||||
return true;
|
||||
|
||||
/* BOLT #7:
|
||||
* - MUST consider whether to send the `channel_announcement` after
|
||||
* receiving the first corresponding `channel_update`.
|
||||
*/
|
||||
if (!have_broadcast_announce)
|
||||
insert_broadcast(rstate->broadcasts, chan->channel_announce);
|
||||
|
||||
insert_broadcast(rstate->broadcasts,
|
||||
chan->half[direction].channel_update);
|
||||
return true;
|
||||
|
|
|
@ -2642,7 +2642,6 @@ class LightningDTests(BaseLightningDTests):
|
|||
for n in [l1, l2, l3]:
|
||||
wait_for(lambda: len(n.rpc.listchannels()['channels']) == 4)
|
||||
|
||||
@unittest.expectedFailure
|
||||
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
|
||||
def test_gossip_no_empty_announcements(self):
|
||||
# Need full IO logging so we can see gossip
|
||||
|
|
Loading…
Add table
Reference in a new issue