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

Function json_waitblockheight

lightningd/peer_control.c:2401–2434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2399 tal_free(to_delete);
2400}
2401static struct command_result *json_waitblockheight(struct command *cmd,
2402 const char *buffer,
2403 const jsmntok_t *obj,
2404 const jsmntok_t *params)
2405{
2406 unsigned int *target_block_height;
2407 u32 block_height;
2408 unsigned int *timeout;
2409 struct waitblockheight_waiter *w;
2410
2411 if (!param(cmd, buffer, params,
2412 p_req("blockheight", param_number, &target_block_height),
2413 p_opt_def("timeout", param_number, &timeout, 60),
2414 NULL))
2415 return command_param_failed();
2416
2417 /* Check if already reached anyway. */
2418 block_height = get_block_height(cmd->ld->topology);
2419 if (*target_block_height <= block_height)
2420 return waitblockheight_complete(cmd, block_height);
2421
2422 /* Create a new waitblockheight command. */
2423 w = tal(cmd, struct waitblockheight_waiter);
2424 tal_add_destructor(w, &destroy_waitblockheight_waiter);
2425 list_add(&cmd->ld->waitblockheight_commands, &w->list);
2426 w->cmd = cmd;
2427 w->block_height = *target_block_height;
2428 w->removed = false;
2429 /* Install the timeout. */
2430 (void) new_reltimer(cmd->ld->timers, w, time_from_sec(*timeout),
2431 &timeout_waitblockheight_waiter, w);
2432
2433 return command_still_pending(cmd);
2434}
2435
2436static const struct json_command waitblockheight_command = {
2437 "waitblockheight",

Callers

nothing calls this directly

Calls 6

waitblockheight_completeFunction · 0.85
time_from_secFunction · 0.85
command_param_failedFunction · 0.70
get_block_heightFunction · 0.70
command_still_pendingFunction · 0.70
paramFunction · 0.50

Tested by

no test coverage detected