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

Function graceful_timeout

lightningd/peer_control.c:3143–3191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3141}
3142
3143static void graceful_timeout(struct graceful_waiter *gw)
3144{
3145 struct htlc_out_map_iter outi;
3146 const struct htlc_out *hout;
3147 struct htlc_in_map_iter ini;
3148 const struct htlc_in *hin;
3149 struct peer *peer;
3150 struct peer_node_id_map_iter it;
3151 struct lightningd *ld = gw->cmd->ld;
3152 u32 *heights = tal_arr(tmpctx, u32, 0);
3153 struct node_id *peers = tal_arr(tmpctx, struct node_id, 0);
3154 struct json_stream *result;
3155
3156 /* Report on any remaining htlcs */
3157 for (hout = htlc_out_map_first(ld->htlcs_out, &outi);
3158 hout;
3159 hout = htlc_out_map_next(ld->htlcs_out, &outi)) {
3160 tal_arr_expand(&heights, hout->cltv_expiry);
3161 }
3162 for (hin = htlc_in_map_first(ld->htlcs_in, &ini);
3163 hin;
3164 hin = htlc_in_map_next(ld->htlcs_in, &ini)) {
3165 tal_arr_expand(&heights, hin->cltv_expiry);
3166 }
3167
3168 asort(heights, tal_count(heights), cmp_height, NULL);
3169
3170 for (peer = peer_node_id_map_first(ld->peers, &it);
3171 peer;
3172 peer = peer_node_id_map_next(ld->peers, &it)) {
3173 if (peer->connected != PEER_DISCONNECTED)
3174 tal_arr_expand(&peers, peer->id);
3175 }
3176
3177 result = json_stream_success(gw->cmd);
3178 if (tal_count(heights)) {
3179 json_array_start(result, "pending_htlc_expiries");
3180 for (size_t i = 0; i < tal_count(heights); i++)
3181 json_add_u32(result, NULL, heights[i]);
3182 json_array_end(result);
3183 }
3184 if (tal_count(peers)) {
3185 json_array_start(result, "pending_peers");
3186 for (size_t i = 0; i < tal_count(peers); i++)
3187 json_add_node_id(result, NULL, &peers[i]);
3188 json_array_end(result);
3189 }
3190 was_pending(command_success(gw->cmd, result));
3191}
3192
3193void check_graceful_shutdown(struct lightningd *ld)
3194{

Callers

nothing calls this directly

Calls 7

json_array_startFunction · 0.85
json_add_u32Function · 0.85
json_array_endFunction · 0.85
json_add_node_idFunction · 0.85
json_stream_successFunction · 0.70
was_pendingFunction · 0.70
command_successFunction · 0.70

Tested by

no test coverage detected