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

Function graceful_timeout

lightningd/peer_control.c:3421–3469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3419}
3420
3421static void graceful_timeout(struct graceful_waiter *gw)
3422{
3423 struct htlc_out_map_iter outi;
3424 const struct htlc_out *hout;
3425 struct htlc_in_map_iter ini;
3426 const struct htlc_in *hin;
3427 struct peer *peer;
3428 struct peer_node_id_map_iter it;
3429 struct lightningd *ld = gw->cmd->ld;
3430 u32 *heights = tal_arr(tmpctx, u32, 0);
3431 struct node_id *peers = tal_arr(tmpctx, struct node_id, 0);
3432 struct json_stream *result;
3433
3434 /* Report on any remaining htlcs */
3435 for (hout = htlc_out_map_first(ld->htlcs_out, &outi);
3436 hout;
3437 hout = htlc_out_map_next(ld->htlcs_out, &outi)) {
3438 tal_arr_expand(&heights, hout->cltv_expiry);
3439 }
3440 for (hin = htlc_in_map_first(ld->htlcs_in, &ini);
3441 hin;
3442 hin = htlc_in_map_next(ld->htlcs_in, &ini)) {
3443 tal_arr_expand(&heights, hin->cltv_expiry);
3444 }
3445
3446 asort(heights, tal_count(heights), cmp_height, NULL);
3447
3448 for (peer = peer_node_id_map_first(ld->peers, &it);
3449 peer;
3450 peer = peer_node_id_map_next(ld->peers, &it)) {
3451 if (peer->connected != PEER_DISCONNECTED)
3452 tal_arr_expand(&peers, peer->id);
3453 }
3454
3455 result = json_stream_success(gw->cmd);
3456 if (tal_count(heights)) {
3457 json_array_start(result, "pending_htlc_expiries");
3458 for (size_t i = 0; i < tal_count(heights); i++)
3459 json_add_u32(result, NULL, heights[i]);
3460 json_array_end(result);
3461 }
3462 if (tal_count(peers)) {
3463 json_array_start(result, "pending_peers");
3464 for (size_t i = 0; i < tal_count(peers); i++)
3465 json_add_node_id(result, NULL, &peers[i]);
3466 json_array_end(result);
3467 }
3468 was_pending(command_success(gw->cmd, result));
3469}
3470
3471void check_graceful_shutdown(struct lightningd *ld)
3472{

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