noise: adds docstrings to plugin methods

This commit is contained in:
Michael Schmoock
2022-02-21 10:04:15 +01:00
parent 69e02e23b1
commit 689be5a70d

View File

@@ -119,6 +119,10 @@ def deliver(node_id, payload, amt, payment_hash, max_attempts=5):
@plugin.async_method('sendmsg')
def sendmsg(node_id, msg, plugin, request, pay=None, **kwargs):
"""Sends a chat message.
First paramter is the message payload as a string.
"""
timestamp = struct.pack("!Q", int(time.time() * 1000))
payload = TlvPayload()
payload.add_field(TLV_NOISE_MESSAGE, msg.encode('UTF-8'))
@@ -151,6 +155,11 @@ def sendmsg(node_id, msg, plugin, request, pay=None, **kwargs):
@plugin.async_method('recvmsg')
def recvmsg(plugin, request, last_id=None, **kwargs):
"""Receives a chat message.
Returns a `concurrent.futures.Future`.
Optional parameter `last_id` can be supplied to return an older message.
"""
next_id = int(last_id) + 1 if last_id is not None else len(plugin.messages)
if next_id <= len(plugin.messages):
res = plugin.messages[int(last_id)].to_dict()