Files
palladum-lightning/lightningd/wait.h
Rusty Russell 6c626b124b lightningd: add chainmoves and channelmoves to wait command.
Only makes sense to wait on creation, since they neither are deleted
nor updated.

We also enhance the list commands to take the standard index options.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `wait`: new subsystems `chainmoves` and `channelmoves`.
2025-08-19 13:37:50 +09:30

78 lines
2.1 KiB
C

#ifndef LIGHTNING_LIGHTNINGD_WAIT_H
#define LIGHTNING_LIGHTNINGD_WAIT_H
#include "config.h"
#include <common/json_param.h>
struct lightningd;
/* This WAIT_SUBSYSTEM_X corresponds to listXs */
enum wait_subsystem {
WAIT_SUBSYSTEM_FORWARD,
WAIT_SUBSYSTEM_SENDPAY,
WAIT_SUBSYSTEM_INVOICE,
WAIT_SUBSYSTEM_HTLCS,
WAIT_SUBSYSTEM_CHAINMOVES,
WAIT_SUBSYSTEM_CHANNELMOVES,
};
#define NUM_WAIT_SUBSYSTEM (WAIT_SUBSYSTEM_CHANNELMOVES+1)
enum wait_index {
WAIT_INDEX_CREATED,
WAIT_INDEX_UPDATED,
WAIT_INDEX_DELETED,
};
#define NUM_WAIT_INDEX (WAIT_INDEX_DELETED+1)
/**
* structure for keeping created/updated/deleted indexes in the db
*/
struct indexes {
u64 i[NUM_WAIT_INDEX];
};
/* Get a string */
const char *wait_index_name(enum wait_index index);
const char *wait_subsystem_name(enum wait_subsystem subsystem);
/**
* wait_index_increment - increment an index, tell waiters.
* @ld: the lightningd
* @subsystem: subsystem for index
* @index: which index
* ...: name/value pairs, followed by NULL.
*
* Increase index, write to db, wake any waiters, give them any name/value pairs.
* If the value is NULL, omit that name.
* If the name starts with '=', the value is a JSON literal (and skip over the =)
*
* Returns the updated index value (always > 0).
*/
u64 LAST_ARG_NULL wait_index_increment(struct lightningd *ld,
enum wait_subsystem subsystem,
enum wait_index index,
...);
/**
* wait_index_increase - increase an index, tell waiters.
* @ld: the lightningd
* @subsystem: subsystem for index
* @index: which index
* @num: number to add (if > 0).
* ...: name/value pairs, followed by NULL.
*
* A more generic version if wait_index_increment: if num is 0 it's a noop.
*/
void LAST_ARG_NULL wait_index_increase(struct lightningd *ld,
enum wait_subsystem subsystem,
enum wait_index index,
u64 num,
...);
/* For passing in index parameters. */
struct command_result *param_index(struct command *cmd, const char *name,
const char *buffer,
const jsmntok_t *tok,
enum wait_index **index);
#endif /* LIGHTNING_LIGHTNINGD_WAIT_H */