Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow hook chaining for the htlc_accepted hook #3489

Merged
merged 9 commits into from
Feb 11, 2020

Commits on Feb 11, 2020

  1. 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.
    cdecker authored and rustyrussell committed Feb 11, 2020
    Configuration menu
    Copy the full SHA
    6b5f510 View commit details
    Browse the repository at this point in the history
  2. plugin: Multiple plugins can register a singl hook

    Switch from having a single plugin to a list of plugins. If the hook is of
    type single we will enforce that constraint on the number of registered
    plugins when attempting to add.
    cdecker authored and rustyrussell committed Feb 11, 2020
    Configuration menu
    Copy the full SHA
    b4e69c6 View commit details
    Browse the repository at this point in the history
  3. plugin: Internalize plugin_hook call payload in the request struct

    We are about to call multiple plugins, and we'll have to pass the payload into
    each call. Sadly the serialized stream gets consumed during the call, so keep
    the unserialized payload around.
    cdecker authored and rustyrussell committed Feb 11, 2020
    Configuration menu
    Copy the full SHA
    532238a View commit details
    Browse the repository at this point in the history
  4. plugin: Split plugin_hook_call_ into initialization and call_next

    We will be using `plugin_hook_call_next` as part of the loop to traverse all
    plugins that registered the hook, so group initialization in the init function
    and move per-plugin logic into `plugin_hook_call_next`
    cdecker authored and rustyrussell committed Feb 11, 2020
    Configuration menu
    Copy the full SHA
    b9f6153 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    ca1d5fc View commit details
    Browse the repository at this point in the history
  6. plugin: Remove special case for plugin stopping while handling hooks

    This used to be necessary because we allocated the `plugin_hook_request` off
    of the plugin instance (only tal allocated object we could grab at that
    time. Now the plugin was replaced by a list, which itself is tal-allocated,
    making that workaround pointless, or even wrong once we have multiple plugins
    registering for that hook.
    cdecker authored and rustyrussell committed Feb 11, 2020
    Configuration menu
    Copy the full SHA
    101b5d5 View commit details
    Browse the repository at this point in the history
  7. plugin: Allow multiple plugins to register the htlc_accepted hook

    Make the `htlc_accepted` hook the first chained hook in our repertoire. The
    plugins are called one after the other in order until we have no more plugins
    or the HTLC was handled by one of the plugins. If no plugins handles the HTLC
    we continue to handle it internally like always.
    
    Handling in this case means the plugin returns either `{"result": "resolve",
    ...}` or `{"result": "fail", ...}`.
    
    Changelog-Changed: plugin: Multiple plugins can now register for the htlc_accepted hook.
    cdecker authored and rustyrussell committed Feb 11, 2020
    Configuration menu
    Copy the full SHA
    ba9c559 View commit details
    Browse the repository at this point in the history
  8. doc: Reduce useless nesting in plugins.md

    Triple nesting seems a bit excessive, I can't even read the titles in the
    sidebar of http://lightning.readthedocs.org anymore :-)
    cdecker authored and rustyrussell committed Feb 11, 2020
    Configuration menu
    Copy the full SHA
    dc5714f View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    d8c2a05 View commit details
    Browse the repository at this point in the history