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
A couple things about the new hooks... #3339
Comments
Thanks @jarret for reporting this. Indeed the hooks have grown organically for a while now, so it might be time to define some conventions. I quite like the more explicit version of the return: {"result": "continue"} this allows us to extend the result in future if we need to get more info from the hook. It also has the advantage of not being binary when compared to booleans. That means we can have more verbs to instruct the node. Depending on context we might have the following verbs as a response:
I don't thing we're replacing notifications with hooks, though they might get a lot more similar once we start chaining hooks and allow mulitple plugins to subscribe to a hook. Notifications are parallel, hooks sequential. The naming conflict is a bit unfortunate, but they are treated orthogonally to each other, so besides the confusion of whether it's a hook or a notification there isn't much that can go wrong. What would you suggest to make the distinction clearer?
Definitely, the
My rationale for chosing the names for hooks and notifications was |
Yeah, I like being maximally explicit with JSON - the human-readable quality is the benefit anyway, so a The only minor issue I can imagine with
One thought I had was a design fix where each hook also becomes a notification by default, such that you are able to optionally register for all the hooks as a notification. If registered as such, it would then default to the 'do nothing' return behavior of the hook. It might be that a common use of many of the hooks is to just snoop on the info (i.e. just use them exactly like they are a notification).
That sounds alright now that I understand it. I am not particularly studied on internals of the implementation, so I am reading the docs with the internals being a bit of a black box to me. Not sure whether that is a good thing or a bad thing at this point. 😋 |
This becomes possible with hook chaining, but there is a performance penalty involved. Hooks are synchronous and |
Looking at the code, Proposal:
|
And then there is the new |
I experimented with writing a plugin that registered for all the hooks in
v0.8.0rc1
. Actually, an extended version of the ZeroMQ plugin under review here: lightningd/plugins#70My experimental version that registers for hooks is here: https://github.com/jarret/plugins/blob/zmqhooks/zmq/cl-zmq.py
Here are a few nits that I encountered:
it would be nicer if they had a consistent way to signal the "do nothing" case.
The
invoice_payment
hook name collides with theinvoice_payment
notification name. It makes naming variables and corresponding options tricky. (is the notification going to get deprecated in favor of the hook in the future, perhaps?).I am not sure if (via the pyln-client framework) returning
True
is the right thing to do for thedb_write
hook. I also don't want to experiment with my mainnet node since it sounds like it will corrupt the database if I do it wrong. A clearer example for how it is to be correctly used would be helpful.The
openchannel
hook doesn't have an underscore in its name. I might expect it to be namedopen_channel
following convention of the others.The text was updated successfully, but these errors were encountered: