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

Function peer_channels_cleanup

lightningd/peer_control.c:154–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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