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

@@ -305,7 +305,7 @@ bool invoices_create(struct invoices *invoices,
db_exec_prepared(invoices->db, stmt);
pinvoice->id = sqlite3_last_insert_rowid(invoices->db->sql);
pinvoice->id = db_last_insert_id(invoices->db);
/* Install expiration trigger. */
if (!invoices->expiration_timer ||
@@ -392,7 +392,7 @@ bool invoices_delete(struct invoices *invoices,
sqlite3_bind_int64(stmt, 1, invoice.id);
db_exec_prepared(invoices->db, stmt);
if (sqlite3_changes(invoices->db->sql) != 1)
if (db_changes(invoices->db) != 1)
return false;
/* Tell all the waiters about the fact that it was deleted. */