* wallet_utxoset_prune -- Remove spent UTXO entries that are old */
| 3751 | * wallet_utxoset_prune -- Remove spent UTXO entries that are old |
| 3752 | */ |
| 3753 | static void wallet_utxoset_prune(struct wallet *w, const u32 blockheight) |
| 3754 | { |
| 3755 | struct db_stmt *stmt; |
| 3756 | |
| 3757 | stmt = db_prepare_v2( |
| 3758 | w->db, |
| 3759 | SQL("SELECT txid, outnum FROM utxoset WHERE spendheight < ?")); |
| 3760 | db_bind_int(stmt, 0, blockheight - UTXO_PRUNE_DEPTH); |
| 3761 | db_query_prepared(stmt); |
| 3762 | |
| 3763 | while (db_step(stmt)) { |
| 3764 | struct bitcoin_outpoint outpoint; |
| 3765 | db_col_txid(stmt, "txid", &outpoint.txid); |
| 3766 | outpoint.n = db_col_int(stmt, "outnum"); |
| 3767 | outpointfilter_remove(w->utxoset_outpoints, &outpoint); |
| 3768 | } |
| 3769 | tal_free(stmt); |
| 3770 | |
| 3771 | stmt = db_prepare_v2(w->db, |
| 3772 | SQL("DELETE FROM utxoset WHERE spendheight < ?")); |
| 3773 | db_bind_int(stmt, 0, blockheight - UTXO_PRUNE_DEPTH); |
| 3774 | db_exec_prepared_v2(take(stmt)); |
| 3775 | } |
| 3776 | |
| 3777 | void wallet_block_add(struct wallet *w, struct block *b) |
| 3778 | { |
no test coverage detected