Skip to content

Commit

Permalink
fixup! pyln: add support for dependent hooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
rustyrussell committed Nov 6, 2020
1 parent 6b8ead0 commit 6a6292e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions contrib/pyln-client/pyln/client/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ def decorator(f: Callable[..., JSONType]) -> Callable[..., JSONType]:

def add_hook(self, name: str, func: Callable[..., JSONType],
background: bool = False,
before: List[str] = [],
after: List[str] = []) -> None:
before: List[str] = None,
after: List[str] = None) -> None:
"""Register a hook that is called synchronously by lightningd on events
"""
if name in self.methods:
Expand All @@ -431,13 +431,15 @@ def add_hook(self, name: str, func: Callable[..., JSONType],

method = Method(name, func, MethodType.HOOK)
method.background = background
method.before = before
method.after = after
if before:
method.before = before
if after:
method.after = after
self.methods[name] = method

def hook(self, method_name: str,
before: List[str] = [],
after: List[str] = []) -> JsonDecoratorType:
before: List[str] = None,
after: List[str] = None) -> JsonDecoratorType:
"""Decorator to add a plugin hook to the dispatch table.
Internally uses add_hook.
Expand Down

0 comments on commit 6a6292e

Please sign in to comment.