~ This is where connectd tells us about a new peer we might want to * gossip with. */
| 388 | /*~ This is where connectd tells us about a new peer we might want to |
| 389 | * gossip with. */ |
| 390 | static 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 | |
| 431 | static void connectd_peer_gone(struct daemon *daemon, const u8 *msg) |
| 432 | { |
no test coverage detected