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

Function clean_finished

plugins/autoclean.c:272–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272static struct command_result *clean_finished(struct clean_info *cinfo)
273{
274 struct subsystem_and_variant sv = first_sv();
275 do {
276 size_t num_cleaned = get_per_variant(cinfo, &sv)->num_cleaned;
277
278 if (!num_cleaned)
279 continue;
280
281 plugin_log(plugin, LOG_DBG, "cleaned %zu from %s",
282 num_cleaned, subsystem_to_str(&sv));
283 *total_cleaned(&sv) += num_cleaned;
284 jsonrpc_set_datastore_string(cinfo->cmd,
285 datastore_path(tmpctx, &sv, "num"),
286 tal_fmt(tmpctx, "%"PRIu64,
287 *total_cleaned(&sv)),
288 "create-or-replace", NULL, NULL, NULL);
289 } while (next_sv(&sv));
290
291 /* autoclean-once? */
292 if (cinfo != timer_cinfo) {
293 struct json_stream *response = jsonrpc_stream_success(cinfo->cmd);
294
295 json_object_start(response, "autoclean");
296
297 sv = first_sv();
298 do {
299 const struct per_variant *pv = get_per_variant(cinfo, &sv);
300 if (pv->age == 0)
301 continue;
302 json_object_start(response, subsystem_to_str(&sv));
303 json_add_u64(response, "cleaned", pv->num_cleaned);
304 json_add_u64(response, "uncleaned",
305 get_per_subsystem(cinfo, &sv)->num_uncleaned);
306 json_object_end(response);
307 } while (next_sv(&sv));
308 json_object_end(response);
309 return command_finished(cinfo->cmd, response);
310 } else { /* timer */
311 plugin_log(plugin, LOG_DBG, "setting next timer");
312 cleantimer = global_timer(plugin,
313 time_from_sec(cycle_seconds),
314 do_clean_timer, NULL);
315 return timer_complete(cinfo->cmd);
316 }
317}
318
319static struct command_result *do_clean_after_sleep(struct command *timer_cmd,
320 struct clean_info *cinfo)

Callers 1

do_cleanFunction · 0.85

Calls 15

first_svFunction · 0.85
get_per_variantFunction · 0.85
subsystem_to_strFunction · 0.85
total_cleanedFunction · 0.85
datastore_pathFunction · 0.85
next_svFunction · 0.85
json_object_startFunction · 0.85
json_add_u64Function · 0.85
get_per_subsystemFunction · 0.85
json_object_endFunction · 0.85
time_from_secFunction · 0.85
timer_completeFunction · 0.85

Tested by

no test coverage detected