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

Function connectd_new_peer

gossipd/gossipd.c:390–429  ·  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

388/*~ This is where connectd tells us about a new peer we might want to
389 * gossip with. */
390static void connectd_new_peer(struct daemon *daemon, const u8 *msg)
391{
392 struct peer *peer = tal(daemon, struct peer);
393 struct node *node;
394
395 if (!fromwire_gossipd_new_peer(msg, &peer->id,
396 &peer->gossip_queries_feature)) {
397 status_failed(STATUS_FAIL_INTERNAL_ERROR,
398 "Bad new_peer msg from connectd: %s",
399 tal_hex(tmpctx, msg));
400 }
401
402 if (find_peer(daemon, &peer->id)) {
403 status_broken("Peer %s already here?",
404 type_to_string(tmpctx, struct node_id, &peer->id));
405 tal_free(find_peer(daemon, &peer->id));
406 }
407
408 /* Populate the rest of the peer info. */
409 peer->daemon = daemon;
410 peer->gossip_counter = 0;
411 peer->scid_queries = NULL;
412 peer->scid_query_idx = 0;
413 peer->scid_query_nodes = NULL;
414 peer->scid_query_nodes_idx = 0;
415 peer->scid_query_outstanding = false;
416 peer->range_replies = NULL;
417 peer->query_channel_range_cb = NULL;
418
419 /* We keep a list so we can find peer by id */
420 list_add_tail(&peer->daemon->peers, &peer->list);
421 tal_add_destructor(peer, destroy_peer);
422
423 node = get_node(daemon->rstate, &peer->id);
424 if (node)
425 peer_enable_channels(daemon, node);
426
427 /* This sends the initial timestamp filter. */
428 seeker_setup_peer_gossip(daemon->seeker, peer);
429}
430
431static void connectd_peer_gone(struct daemon *daemon, const u8 *msg)
432{

Callers 1

connectd_reqFunction · 0.85

Calls 8

tal_hexFunction · 0.85
tal_freeFunction · 0.85
peer_enable_channelsFunction · 0.85
seeker_setup_peer_gossipFunction · 0.85
find_peerFunction · 0.70
get_nodeFunction · 0.70
status_failedFunction · 0.50
type_to_stringClass · 0.50

Tested by

no test coverage detected