db: make db_set_visible_state called from within transaction.

We want to do this atomically; this is the first step.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-11-09 08:04:25 +10:30
parent 8c5fae2b28
commit 6acb4953b1
3 changed files with 7 additions and 8 deletions

View File

@@ -32,7 +32,9 @@ static Pkt *init_from_pkt_open(struct peer *peer, const Pkt *pkt)
if (err)
return err;
if (!db_set_visible_state(peer))
db_start_transaction(peer);
db_set_visible_state(peer);
if (db_commit_transaction(peer) != NULL)
return pkt_err(peer, "Database error");
/* Set up their commit info now: rest gets done in setup_first_commit