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