mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
[plugin] Improved the example code to encourage usage of optional arguments (#2212)
The example code had the `plugin` argument as the last argument. this disallows arguments that have a standard value. As far as I understand the dispatching code the order of arguments does not matter since it is the name `plugin` that is relevant. Therefor I changed the order so that newbe's don't have to read the entire code and can easily add optional arguments
This commit is contained in:
committed by
Christian Decker
parent
3aecede214
commit
0321d79540
@@ -6,7 +6,7 @@ plugin = Plugin(autopatch=True)
|
|||||||
|
|
||||||
|
|
||||||
@plugin.method("hello")
|
@plugin.method("hello")
|
||||||
def hello(name, plugin):
|
def hello(plugin, name="world"):
|
||||||
"""This is the documentation string for the hello-function.
|
"""This is the documentation string for the hello-function.
|
||||||
|
|
||||||
It gets reported as the description when registering the function
|
It gets reported as the description when registering the function
|
||||||
@@ -25,12 +25,12 @@ def init(options, configuration, plugin):
|
|||||||
|
|
||||||
|
|
||||||
@plugin.subscribe("connect")
|
@plugin.subscribe("connect")
|
||||||
def on_connect(id, address, plugin):
|
def on_connect(plugin, id, address):
|
||||||
plugin.log("Received connect event for peer {}".format(id))
|
plugin.log("Received connect event for peer {}".format(id))
|
||||||
|
|
||||||
|
|
||||||
@plugin.subscribe("disconnect")
|
@plugin.subscribe("disconnect")
|
||||||
def on_disconnect(id, plugin):
|
def on_disconnect(plugin, id):
|
||||||
plugin.log("Received disconnect event for peer {}".format(id))
|
plugin.log("Received disconnect event for peer {}".format(id))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user