mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 00:54:20 +01:00
db: add generic warn/error function.
This avoids the mess where we override db_fatal for teqsts, and keeps it generic. Also allows us to get rid of one #if DEVELOPER, and an ugly global for bookkeeper. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
17
db/utils.h
17
db/utils.h
@@ -85,7 +85,15 @@ struct db_stmt *db_prepare_v2_(const char *location, struct db *db,
|
||||
/**
|
||||
* db_open - Open or create a database
|
||||
*/
|
||||
struct db *db_open(const tal_t *ctx, const char *filename);
|
||||
#define db_open(ctx, filename, errfn, arg) \
|
||||
db_open_((ctx), (filename), \
|
||||
typesafe_cb_postargs(void, void *, (errfn), (arg), \
|
||||
bool, const char *, va_list), \
|
||||
(arg))
|
||||
|
||||
struct db *db_open_(const tal_t *ctx, const char *filename,
|
||||
void (*errorfn)(void *arg, bool fatal, const char *fmt, va_list ap),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Report a statement that changes the wallet
|
||||
@@ -110,4 +118,11 @@ const char **db_changes(struct db *db);
|
||||
* to re-use the normal db hook and replication logic.
|
||||
*/
|
||||
struct db_stmt *db_prepare_untranslated(struct db *db, const char *query);
|
||||
|
||||
/* Errors and warnings... */
|
||||
void db_fatal(const struct db *db, const char *fmt, ...)
|
||||
PRINTF_FMT(2, 3);
|
||||
void db_warn(const struct db *db, const char *fmt, ...)
|
||||
PRINTF_FMT(2, 3);
|
||||
|
||||
#endif /* LIGHTNING_DB_UTILS_H */
|
||||
|
||||
Reference in New Issue
Block a user