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

Function disconnect_idle_peers

lightningd/peer_control.c:3011–3039  ·  view source on GitHub ↗

Returns number currently connected */

Source from the content-addressed store, hash-verified

3009
3010/* Returns number currently connected */
3011static size_t disconnect_idle_peers(struct lightningd *ld)
3012{
3013 struct peer *peer;
3014 struct peer_node_id_map_iter it;
3015 size_t num_connected = 0;
3016
3017 for (peer = peer_node_id_map_first(ld->peers, &it);
3018 peer;
3019 peer = peer_node_id_map_next(ld->peers, &it)) {
3020 bool all_idle = true;
3021 const struct channel *channel;
3022
3023 if (peer->connected == PEER_DISCONNECTED)
3024 continue;
3025
3026 num_connected++;
3027 list_for_each(&peer->channels, channel, list) {
3028 if (!ignore_idle_channel(ld, channel))
3029 all_idle = false;
3030 }
3031 /* We can't use force_peer_disconnect here, since we must not
3032 * free the channel: make a timer do the dirty work! */
3033 if (all_idle) {
3034 new_reltimer(ld->timers, peer, time_from_sec(0),
3035 graceful_disconnect, peer);
3036 }
3037 }
3038 return num_connected;
3039}
3040
3041struct graceful_waiter {
3042 struct list_node list;

Callers 1

Calls 2

ignore_idle_channelFunction · 0.85
time_from_secFunction · 0.85

Tested by

no test coverage detected