wallet: Add primitive to roll back to a specific height

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2018-02-19 14:01:42 +01:00
parent 504202973f
commit 9440b23852
2 changed files with 12 additions and 0 deletions

View File

@ -1689,3 +1689,11 @@ void wallet_block_remove(struct wallet *w, struct block *b)
assert(sqlite3_step(stmt) == SQLITE_DONE);
sqlite3_finalize(stmt);
}
void wallet_blocks_rollback(struct wallet *w, u32 height)
{
sqlite3_stmt *stmt = db_prepare(w->db, "DELETE FROM blocks "
"WHERE height >= ?");
sqlite3_bind_int(stmt, 1, height);
db_exec_prepared(w->db, stmt);
}

View File

@ -695,5 +695,9 @@ void wallet_block_add(struct wallet *w, struct block *b);
*/
void wallet_block_remove(struct wallet *w, struct block *b);
/**
* wallet_blocks_rollback - Roll the blockchain back to the given height
*/
void wallet_blocks_rollback(struct wallet *w, u32 height);
#endif /* WALLET_WALLET_H */