We take over the --bookkeeper-dir and --bookkeeper-db options, and then if we can find the bookkeeper db we extract the records to initialize our chain_moves and channel_moves tables. Of course, bookkeeper now needs to not register those options. When bookkeeper gets invoked the first time, it will reconstruct everything from listchannelmoves and listcoinmoves. It cannot preserve manually-added descriptions, so we put those in the datastore for it ready to go. Note that the order of onchain_fee changes slightly from the original. But this is fine. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
80 lines
2.2 KiB
C
80 lines
2.2 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
|
|
* @db: the database (usually ld->wallet->db, except really early)
|
|
* @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,
|
|
struct db *db,
|
|
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 */
|