Browse Source

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>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
5e46af64fc
  1. 5
      wallet/db.c
  2. 2
      wallet/db.h

5
wallet/db.c

@ -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;
}

2
wallet/db.h

@ -15,7 +15,7 @@
struct db {
char *filename;
bool in_transaction;
unsigned int in_transaction;
const char *err;
sqlite3 *sql;
};

Loading…
Cancel
Save