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

Function peer_channels_cleanup

lightningd/peer_control.c:161–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161void peer_channels_cleanup(struct peer *peer)
162{
163 struct channel *c, **channels;
164
165 /* Freeing channels can free peer, so gather first. */
166 channels = tal_arr(tmpctx, struct channel *, 0);
167 list_for_each(&peer->channels, c, list)
168 tal_arr_expand(&channels, c);
169
170 if (peer->uncommitted_channel) {
171 /* Frees peer if no channels */
172 kill_uncommitted_channel(peer->uncommitted_channel,
173 "Disconnected");
174 } else if (tal_count(channels) == 0)
175 /* Was completely idle. */
176 tal_free(peer);
177
178 for (size_t i = 0; i < tal_count(channels); i++) {
179 c = channels[i];
180 if (channel_state_wants_peercomms(c->state)) {
181 channel_cleanup_commands(c, "Disconnected");
182 channel_fail_transient(c, true, "Disconnected");
183 } else if (channel_state_uncommitted(c->state)) {
184 channel_unsaved_close_conn(c, "Disconnected");
185 }
186 }
187}
188
189struct peer *find_peer_by_dbid(struct lightningd *ld, u64 dbid)
190{

Callers 2

handle_peer_connectedFunction · 0.85
json_connectFunction · 0.85

Calls 7

tal_freeFunction · 0.85
kill_uncommitted_channelFunction · 0.70
channel_cleanup_commandsFunction · 0.70
channel_fail_transientFunction · 0.70

Tested by

no test coverage detected