libplugin: simple timer support.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-05-20 20:40:54 +09:30
committed by Christian Decker
parent c83066f8ed
commit 9b61c19a20
2 changed files with 76 additions and 2 deletions

View File

@@ -55,7 +55,9 @@ const char *rpc_delve(const tal_t *ctx,
const char *method, const char *params,
struct plugin_conn *rpc, const char *guide);
/* Async rpc request. For convenience, and single ' are turned into ". */
/* Async rpc request. For convenience, and single ' are turned into ".
* @cmd can be NULL if we're coming from a timer callback.
*/
PRINTF_FMT(6,7) struct command_result *
send_outreq_(struct command *cmd,
const char *method,
@@ -96,6 +98,17 @@ struct command_result *forward_result(struct command *cmd,
const jsmntok_t *result,
void *arg);
/* Callback for timer where we expect a 'command_result'. */
struct command_result *timer_complete(void);
/* Access timer infrastructure to add a timer.
*
* Freeing this releases the timer (don't free it in timer cb though)
*/
struct plugin_timer *plugin_timer(struct plugin_conn *rpc,
struct timerel t,
struct command_result *(*cb)(void));
/* Macro to define arguments */
#define plugin_option(name, description, set, arg) \
(name), \