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

Function db_hook_response

lightningd/plugin_hook.c:432–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430};
431
432static void db_hook_response(const char *buffer, const jsmntok_t *toks,
433 const jsmntok_t *idtok,
434 struct db_write_hook_req *dwh_req)
435{
436 const jsmntok_t *resulttok;
437
438 resulttok = json_get_member(buffer, toks, "result");
439 if (!resulttok)
440 fatal("Plugin '%s' returned an invalid response to the "
441 "db_write hook: %.*s",
442 dwh_req->plugin->cmd,
443 json_tok_full_len(toks),
444 json_tok_full(buffer, toks));
445
446 /* We expect result: { 'result' : 'continue' }.
447 * Anything else we abort.
448 */
449 resulttok = json_get_member(buffer, resulttok, "result");
450 if (resulttok) {
451 if (!json_tok_streq(buffer, resulttok, "continue"))
452 fatal("Plugin '%s' returned failed db_write: %.*s.",
453 dwh_req->plugin->cmd,
454 json_tok_full_len(toks),
455 json_tok_full(buffer, toks));
456 } else
457 fatal("Plugin '%s' returned an invalid result to the db_write "
458 "hook: %.*s",
459 dwh_req->plugin->cmd,
460 json_tok_full_len(toks),
461 json_tok_full(buffer, toks));
462
463 assert((*dwh_req->num_hooks) != 0);
464 --(*dwh_req->num_hooks);
465 /* If there are other runners, do not exit yet. */
466 if ((*dwh_req->num_hooks) != 0)
467 return;
468
469 /* We're done, exit exclusive loop. */
470 log_debug(dwh_req->plugin->plugins->ld->log, "io_break: %s", __func__);
471 io_break(dwh_req->ph_req);
472}
473
474void plugin_hook_db_sync(struct db *db)
475{

Callers

nothing calls this directly

Calls 6

json_get_memberFunction · 0.85
json_tok_streqFunction · 0.85
io_breakFunction · 0.85
fatalFunction · 0.70
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50

Tested by

no test coverage detected