Browse Source

wallet: Add primitive to roll back to a specific height

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
parent
commit
9440b23852
  1. 8
      wallet/wallet.c
  2. 4
      wallet/wallet.h

8
wallet/wallet.c

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

4
wallet/wallet.h

@ -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 */

Loading…
Cancel
Save