-
Notifications
You must be signed in to change notification settings - Fork 901
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
Order specifications for hooks #4168
Changes from all commits
11a0e38
f86b66b
b5cab17
05fe058
c3afd29
3101bef
5124378
2ca13b2
77c27af
0ed8a0c
ed8f556
7d41997
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,8 +93,8 @@ example: | |
"disconnect" | ||
], | ||
"hooks": [ | ||
"openchannel", | ||
"htlc_accepted" | ||
{ "name": "openchannel", "before": ["another_plugin"] }, | ||
{ "name": "htlc_accepted" } | ||
], | ||
"features": { | ||
"node": "D0000000", | ||
|
@@ -678,14 +678,25 @@ declares that it'd like to be consulted on what to do next for certain | |
events in the daemon. A hook can then decide how `lightningd` should | ||
react to the given event. | ||
|
||
When hooks are registered, they can optionally specify "before" and | ||
"after" arrays of plugin names, which control what order they will be | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. General question about 'plugin names': Is this same as for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, filename or full path name. |
||
called in. If a plugin name is unknown, it is ignored, otherwise if the | ||
hook calls cannot be ordered to satisfy the specifications of all | ||
plugin hooks, the plugin registration will fail. | ||
|
||
The call semantics of the hooks, i.e., when and how hooks are called, depend | ||
on the hook type. Most hooks are currently set to `single`-mode. In this mode | ||
only a single plugin can register the hook, and that plugin will get called | ||
for each event of that type. If a second plugin attempts to register the hook | ||
it gets killed and a corresponding log entry will be added to the logs. In | ||
`chain`-mode multiple plugins can register for the hook type and they are | ||
called sequentially if a matching event is triggered. Each plugin can then | ||
handle the event or defer by returning a `continue` result like the following: | ||
it gets killed and a corresponding log entry will be added to the logs. | ||
|
||
In `chain`-mode multiple plugins can register for the hook type and | ||
they are called in any order they are loaded (i.e. cmdline order | ||
first, configuration order file second: though note that the order of | ||
plugin directories is implementation-dependent), overriden only by | ||
`before` and `after` requirements the plugin's hook registrations specify. | ||
Each plugin can then handle the event or defer by returning a | ||
`continue` result like the following: | ||
|
||
```json | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now becomes an
Optional[List[str]]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for forgetting this in my first round of comments :-)