MCPcopy Create free account
hub / github.com/ElementsProject/lightning / connectd_new_peer

Function connectd_new_peer

gossipd/gossipd.c:117–152  ·  view source on GitHub ↗

~ This is where connectd tells us about a new peer we might want to * gossip with. */

Source from the content-addressed store, hash-verified

115/*~ This is where connectd tells us about a new peer we might want to
116 * gossip with. */
117static void connectd_new_peer(struct daemon *daemon, const u8 *msg)
118{
119 struct peer *peer = tal(daemon, struct peer);
120
121 if (!fromwire_gossipd_new_peer(msg, &peer->id,
122 &peer->gossip_queries_feature)) {
123 status_failed(STATUS_FAIL_INTERNAL_ERROR,
124 "Bad new_peer msg from connectd: %s",
125 tal_hex(tmpctx, msg));
126 }
127
128 if (find_peer(daemon, &peer->id)) {
129 status_broken("Peer %s already here?",
130 fmt_node_id(tmpctx, &peer->id));
131 tal_free(find_peer(daemon, &peer->id));
132 }
133
134 /* Populate the rest of the peer info. */
135 peer->daemon = daemon;
136 peer->gossip_counter = 0;
137 peer->query_reply_counter = 0;
138 peer->scid_queries = NULL;
139 peer->scid_query_idx = 0;
140 peer->scid_query_nodes = NULL;
141 peer->scid_query_nodes_idx = 0;
142 peer->scid_query_outstanding = false;
143 peer->range_replies = NULL;
144 peer->query_channel_range_cb = NULL;
145
146 /* We keep a htable so we can find peer by id */
147 peer_node_id_map_add(daemon->peers, peer);
148 tal_add_destructor(peer, destroy_peer);
149
150 /* This sends the initial timestamp filter. */
151 seeker_setup_peer_gossip(daemon->seeker, peer);
152}
153
154static void connectd_peer_gone(struct daemon *daemon, const u8 *msg)
155{

Callers 1

connectd_reqFunction · 0.85

Calls 6

tal_hexFunction · 0.85
fmt_node_idFunction · 0.85
tal_freeFunction · 0.85
seeker_setup_peer_gossipFunction · 0.85
find_peerFunction · 0.70
status_failedFunction · 0.50

Tested by

no test coverage detected