mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
db: Track the data_version in the database
This increments the `data_version` upon committing dirty transactions, reads the last data_version upon startup, and tracks the number in memory in parallel to the DB (see next commit for rationale). Changelog-Changed: JSON-RPC: Added a `data_version` field to the `db_write` hook which returns a numeric transaction counter.
This commit is contained in:
committed by
neil saitug
parent
4a4184be70
commit
2c11c54dd2
@@ -175,6 +175,8 @@ void plugin_hook_db_sync(struct db *db)
|
||||
ph_req->hook = hook;
|
||||
ph_req->db = db;
|
||||
|
||||
json_add_num(req->stream, "data_version", db_data_version_get(db));
|
||||
|
||||
json_array_start(req->stream, "writes");
|
||||
for (size_t i = 0; i < tal_count(changes); i++)
|
||||
json_add_string(req->stream, NULL, changes[i]);
|
||||
|
||||
Reference in New Issue
Block a user