MCPcopy Create free account
hub / github.com/ElementsProject/lightning / wallet_utxoset_prune

Function wallet_utxoset_prune

wallet/wallet.c:3753–3775  ·  view source on GitHub ↗

* wallet_utxoset_prune -- Remove spent UTXO entries that are old */

Source from the content-addressed store, hash-verified

3751 * wallet_utxoset_prune -- Remove spent UTXO entries that are old
3752 */
3753static 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
3777void wallet_block_add(struct wallet *w, struct block *b)
3778{

Callers 1

wallet_block_addFunction · 0.85

Calls 8

db_bind_intFunction · 0.85
db_query_preparedFunction · 0.85
db_stepFunction · 0.85
db_col_txidFunction · 0.85
db_col_intFunction · 0.85
tal_freeFunction · 0.85
db_exec_prepared_v2Function · 0.85
outpointfilter_removeFunction · 0.70

Tested by

no test coverage detected