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

Function peer_channels_cleanup

lightningd/peer_control.c:144–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144static void peer_channels_cleanup(struct lightningd *ld,
145 const struct node_id *id)
146{
147 struct peer *peer;
148 struct channel *c, **channels;
149
150 peer = peer_by_id(ld, id);
151 if (!peer)
152 return;
153
154 /* Freeing channels can free peer, so gather first. */
155 channels = tal_arr(tmpctx, struct channel *, 0);
156 list_for_each(&peer->channels, c, list)
157 tal_arr_expand(&channels, c);
158
159 if (peer->uncommitted_channel) {
160 /* Frees peer if no channels */
161 kill_uncommitted_channel(peer->uncommitted_channel,
162 "Disconnected");
163 } else if (tal_count(channels) == 0)
164 /* Was completely idle. */
165 tal_free(peer);
166
167 for (size_t i = 0; i < tal_count(channels); i++) {
168 c = channels[i];
169 if (channel_active(c)) {
170 channel_cleanup_commands(c, "Disconnected");
171 channel_fail_transient(c, "Disconnected");
172 } else if (channel_unsaved(c)) {
173 channel_unsaved_close_conn(c, "Disconnected");
174 }
175 }
176}
177
178struct peer *find_peer_by_dbid(struct lightningd *ld, u64 dbid)
179{

Callers 1

peer_connectedFunction · 0.85

Calls 8

peer_by_idFunction · 0.85
tal_freeFunction · 0.85
channel_activeFunction · 0.85
channel_unsavedFunction · 0.85
kill_uncommitted_channelFunction · 0.70
channel_cleanup_commandsFunction · 0.70
channel_fail_transientFunction · 0.70

Tested by

no test coverage detected