mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
gossipd: send our own gossip aggressively when a new peer connects.
This was previously the role of connectd, but it's actually more efficient for us to do it: connectd has to sweep through the entire gossip_store, but we have datastructures for this already. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
ShahanaFarooqui
parent
ba7901bebd
commit
8ef4b36a1f
@@ -402,6 +402,40 @@ update_node_annoucement:
|
||||
maybe_send_own_node_announce(daemon, false);
|
||||
}
|
||||
|
||||
/* BOLT #7:
|
||||
* - if the `gossip_queries` feature is negotiated:
|
||||
* - MUST NOT relay any gossip messages it did not generate itself,
|
||||
* unless explicitly requested.
|
||||
*/
|
||||
/* i.e. the strong implication is that we spam our own gossip aggressively!
|
||||
* "Look at me!" "Look at me!!!!".
|
||||
*/
|
||||
static void dump_our_gossip(struct daemon *daemon, struct peer *peer)
|
||||
{
|
||||
struct node *me;
|
||||
struct chan_map_iter i;
|
||||
struct chan *chan;
|
||||
|
||||
/* Find ourselves; if no channels, nothing to send */
|
||||
me = get_node(daemon->rstate, &daemon->id);
|
||||
if (!me)
|
||||
return;
|
||||
|
||||
for (chan = first_chan(me, &i); chan; chan = next_chan(me, &i)) {
|
||||
int dir;
|
||||
|
||||
if (!is_chan_public(chan))
|
||||
continue;
|
||||
|
||||
/* Send announce */
|
||||
queue_peer_from_store(peer, &chan->bcast);
|
||||
/* Send update if we have one */
|
||||
dir = half_chan_idx(me, chan);
|
||||
if (is_halfchan_defined(&chan->half[dir]))
|
||||
queue_peer_from_store(peer, &chan->half[dir].bcast);
|
||||
}
|
||||
}
|
||||
|
||||
/*~ This is where connectd tells us about a new peer we might want to
|
||||
* gossip with. */
|
||||
static void connectd_new_peer(struct daemon *daemon, const u8 *msg)
|
||||
@@ -441,6 +475,9 @@ static void connectd_new_peer(struct daemon *daemon, const u8 *msg)
|
||||
if (node)
|
||||
peer_enable_channels(daemon, node);
|
||||
|
||||
/* Send everything we know about our own channels */
|
||||
dump_our_gossip(daemon, peer);
|
||||
|
||||
/* This sends the initial timestamp filter. */
|
||||
seeker_setup_peer_gossip(daemon->seeker, peer);
|
||||
}
|
||||
|
||||
@@ -1397,7 +1397,7 @@ def test_gossipwith(node_factory):
|
||||
num_msgs += 1
|
||||
|
||||
# one channel announcement, two channel_updates, two node announcements.
|
||||
assert num_msgs == 5
|
||||
assert num_msgs == 7
|
||||
|
||||
|
||||
def test_gossip_notices_close(node_factory, bitcoind):
|
||||
|
||||
Reference in New Issue
Block a user