mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
db: keep in_transaction as a counter, so we can nest commits.
Otherwise we find ourselves outside a commitment. This is a bandaid until we remove nested commitments again at the end of this series. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
77789bb705
commit
5e46af64fc
@ -235,6 +235,7 @@ bool db_begin_transaction(struct db *db)
|
||||
assert(db->in_transaction);
|
||||
return db->in_transaction;
|
||||
}
|
||||
db->in_transaction++;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -242,7 +243,7 @@ bool db_commit_transaction(struct db *db)
|
||||
{
|
||||
assert(db->in_transaction);
|
||||
bool ret = db_exec(__func__, db, "COMMIT;");
|
||||
db->in_transaction = false;
|
||||
db->in_transaction--;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -250,7 +251,7 @@ bool db_rollback_transaction(struct db *db)
|
||||
{
|
||||
assert(db->in_transaction);
|
||||
bool ret = db_exec(__func__, db, "ROLLBACK;");
|
||||
db->in_transaction = false;
|
||||
db->in_transaction--;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
struct db {
|
||||
char *filename;
|
||||
bool in_transaction;
|
||||
unsigned int in_transaction;
|
||||
const char *err;
|
||||
sqlite3 *sql;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user