mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +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. */
|
/* Channel is now public. */
|
||||||
chan->channel_announce = tal_dup_arr(chan, u8, msg, tal_len(msg), 0);
|
chan->channel_announce = tal_dup_arr(chan, u8, msg, tal_len(msg), 0);
|
||||||
|
|
||||||
/* Now we can broadcast channel announce */
|
/* Clear any private updates: new updates will trigger broadcast of
|
||||||
insert_broadcast(rstate->broadcasts, chan->channel_announce);
|
* this channel_announce. */
|
||||||
|
|
||||||
/* Clear any private updates. */
|
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(chan->half); i++)
|
for (size_t i = 0; i < ARRAY_SIZE(chan->half); i++)
|
||||||
chan->half[i].channel_update
|
chan->half[i].channel_update
|
||||||
= tal_free(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 bitcoin_blkid chain_hash;
|
||||||
struct chan *chan;
|
struct chan *chan;
|
||||||
u8 direction;
|
u8 direction;
|
||||||
|
bool have_broadcast_announce;
|
||||||
|
|
||||||
if (!fromwire_channel_update(update, &signature, &chain_hash,
|
if (!fromwire_channel_update(update, &signature, &chain_hash,
|
||||||
&short_channel_id, ×tamp, &flags,
|
&short_channel_id, ×tamp, &flags,
|
||||||
|
@ -944,6 +943,10 @@ bool routing_add_channel_update(struct routing_state *rstate,
|
||||||
if (!chan)
|
if (!chan)
|
||||||
return false;
|
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;
|
direction = flags & 0x1;
|
||||||
set_connection_values(chan, direction, fee_base_msat,
|
set_connection_values(chan, direction, fee_base_msat,
|
||||||
fee_proportional_millionths, expiry,
|
fee_proportional_millionths, expiry,
|
||||||
|
@ -959,6 +962,13 @@ bool routing_add_channel_update(struct routing_state *rstate,
|
||||||
if (!chan->channel_announce)
|
if (!chan->channel_announce)
|
||||||
return true;
|
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,
|
insert_broadcast(rstate->broadcasts,
|
||||||
chan->half[direction].channel_update);
|
chan->half[direction].channel_update);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -2642,7 +2642,6 @@ class LightningDTests(BaseLightningDTests):
|
||||||
for n in [l1, l2, l3]:
|
for n in [l1, l2, l3]:
|
||||||
wait_for(lambda: len(n.rpc.listchannels()['channels']) == 4)
|
wait_for(lambda: len(n.rpc.listchannels()['channels']) == 4)
|
||||||
|
|
||||||
@unittest.expectedFailure
|
|
||||||
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
|
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
|
||||||
def test_gossip_no_empty_announcements(self):
|
def test_gossip_no_empty_announcements(self):
|
||||||
# Need full IO logging so we can see gossip
|
# Need full IO logging so we can see gossip
|
||||||
|
|
Loading…
Add table
Reference in a new issue