db: Make the db struct private and provide accessors instead

We will soon generalize the DB, so directly reaching into the `struct db`
instance to talk to the sqlite3 connection is bad anyway. This increases
flexibility and allows us to tailor the actual implementation to the
underlying DB.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker
2019-07-23 20:45:06 +02:00
committed by Rusty Russell
parent 66a47d2761
commit 803007ecdf
6 changed files with 46 additions and 16 deletions

View File

@@ -555,7 +555,7 @@ static void destroy_subd(struct subd *sd)
sd->channel = NULL;
/* We can be freed both inside msg handling, or spontaneously. */
outer_transaction = db->in_transaction;
outer_transaction = db_in_transaction(db);
if (!outer_transaction)
db_begin_transaction(db);
if (sd->errcb)

View File

@@ -57,6 +57,9 @@ void db_commit_transaction(struct db *db UNNEEDED)
/* Generated stub for db_get_intvar */
s64 db_get_intvar(struct db *db UNNEEDED, char *varname UNNEEDED, s64 defval UNNEEDED)
{ fprintf(stderr, "db_get_intvar called!\n"); abort(); }
/* Generated stub for db_in_transaction */
bool db_in_transaction(struct db *db UNNEEDED)
{ fprintf(stderr, "db_in_transaction called!\n"); abort(); }
/* Generated stub for fatal */
void fatal(const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "fatal called!\n"); abort(); }