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