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

Function destroy_peer

connectd/connectd.c:207–227  ·  view source on GitHub ↗

~ When we free a peer, we remove it from the daemon's hashtable. * We also call this manually if we want to elegantly drain peer's * queues. */

Source from the content-addressed store, hash-verified

205 * We also call this manually if we want to elegantly drain peer's
206 * queues. */
207void destroy_peer(struct peer *peer)
208{
209 assert(!peer->draining);
210
211 if (!peer_htable_del(&peer->daemon->peers, peer))
212 abort();
213
214 /* Tell gossipd to stop asking this peer gossip queries */
215 daemon_conn_send(peer->daemon->gossipd,
216 take(towire_gossipd_peer_gone(NULL, &peer->id)));
217
218 /* Tell lightningd it's really disconnected */
219 daemon_conn_send(peer->daemon->master,
220 take(towire_connectd_peer_disconnect_done(NULL,
221 &peer->id,
222 peer->counter)));
223 /* This makes multiplex.c routines not feed us more, but
224 * *also* means that if we're freed directly, the ->to_peer
225 * destructor won't call drain_peer(). */
226 peer->draining = true;
227}
228
229/*~ This is where we create a new peer. */
230static struct peer *new_peer(struct daemon *daemon,

Callers 1

drain_peerFunction · 0.70

Calls 2

abortFunction · 0.85
daemon_conn_sendFunction · 0.50

Tested by

no test coverage detected