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

Function plugin_hook_call_

lightningd/plugin_hook.c:381–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379}
380
381bool plugin_hook_call_(struct lightningd *ld,
382 struct plugin_hook *hook,
383 const char *strfilterfield TAKES,
384 u64 intfilterfield,
385 const char *cmd_id TAKES,
386 tal_t *cb_arg STEALS)
387{
388 hook_start(hook);
389 if (tal_count(hook->hooks)) {
390 /* If we have a plugin that has registered for this
391 * hook, serialize and call it */
392 /* FIXME: technically this is a leak, but we don't
393 * currently have a list to store these. We might want
394 * to eventually to inspect in-flight requests. */
395 struct plugin_hook_request *ph_req;
396
397 ph_req = notleak(tal(hook->hooks, struct plugin_hook_request));
398 ph_req->hook = hook;
399 ph_req->cb_arg = tal_steal(ph_req, cb_arg);
400 ph_req->db = ld->wallet->db;
401 ph_req->ld = ld;
402 ph_req->cmd_id = tal_strdup_or_null(ph_req, cmd_id);
403 ph_req->hook_index = -1;
404 ph_req->strfilterfield = tal_strdup_or_null(ph_req, strfilterfield);
405 ph_req->intfilterfield = intfilterfield;
406 return plugin_hook_call_next(ph_req);
407 } else {
408 /* If no plugin has registered for this hook, just
409 * call the callback with a NULL result. Saves us the
410 * roundtrip to the serializer and deserializer. If we
411 * were expecting a default response it should have
412 * been part of the `cb_arg`. */
413 hook_done(ld, hook, cb_arg);
414 return true;
415 }
416}
417
418/* We open-code this, because it's just different and special enough to be
419 * annoying, and to make it clear that it's totally synchronous. */

Callers

nothing calls this directly

Calls 4

hook_startFunction · 0.85
tal_strdup_or_nullFunction · 0.85
plugin_hook_call_nextFunction · 0.85
hook_doneFunction · 0.85

Tested by

no test coverage detected