plugin: Introduce plugin type to allow singleton and chaining

The newly introduced type is used to determine what the call semantics of the
hook are. We have `single` corresponding to the old behavior, as well as
`chain` which allows multiple plugins to register for the hook, and they are
then called sequentially (if all plugins return `{"result": "continue"}`) or
exit the chain if the hook event was handled.
This commit is contained in:
Christian Decker
2020-02-04 12:52:54 +01:00
committed by Rusty Russell
parent 30580731a6
commit 9a2a09efd6
7 changed files with 30 additions and 11 deletions

View File

@@ -130,7 +130,8 @@ void plugin_hook_call_(struct lightningd *ld, const struct plugin_hook *hook,
* annoying, and to make it clear that it's totally synchronous. */
/* Special synchronous hook for db */
static struct plugin_hook db_write_hook = { "db_write", NULL, NULL, NULL };
static struct plugin_hook db_write_hook = {"db_write", PLUGIN_HOOK_SINGLE, NULL,
NULL, NULL};
AUTODATA(hooks, &db_write_hook);
static void db_hook_response(const char *buffer, const jsmntok_t *toks,