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

Function json_wait

lightningd/wait.c:250–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248}
249
250static struct command_result *json_wait(struct command *cmd,
251 const char *buffer,
252 const jsmntok_t *obj UNNEEDED,
253 const jsmntok_t *params)
254{
255 struct waiter *waiter = tal(cmd, struct waiter);
256 u64 val;
257
258 if (!param(cmd, buffer, params,
259 p_req("subsystem", param_subsystem,
260 &waiter->subsystem),
261 p_req("indexname", param_index, &waiter->index),
262 p_req("nextvalue", param_u64, &waiter->nextval),
263 NULL))
264 return command_param_failed();
265
266 /* Are we there already? Return immediately. */
267 val = *wait_index_ptr(cmd->ld, *waiter->subsystem, *waiter->index);
268 if (val >= *waiter->nextval) {
269 struct json_stream *response;
270
271 response = json_stream_success(cmd);
272 json_add_index(cmd, response,
273 *waiter->subsystem,
274 *waiter->index,
275 val, NULL);
276 return command_success(cmd, response);
277 }
278
279 waiter->cmd = cmd;
280 list_add_tail(&cmd->ld->wait_commands, &waiter->list);
281 log_trace(cmd->ld->log, "waiting on %s %s %"PRIu64,
282 wait_subsystem_name(*waiter->subsystem),
283 wait_index_name(*waiter->index),
284 *waiter->nextval);
285 return command_still_pending(cmd);
286}
287
288static const struct json_command wait_command = {
289 "wait",

Callers

nothing calls this directly

Calls 9

wait_index_ptrFunction · 0.85
json_add_indexFunction · 0.85
command_param_failedFunction · 0.70
json_stream_successFunction · 0.70
command_successFunction · 0.70
wait_subsystem_nameFunction · 0.70
wait_index_nameFunction · 0.70
command_still_pendingFunction · 0.70
paramFunction · 0.50

Tested by

no test coverage detected