mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 22:45:27 +01:00
lightningd: only trim old UTXO entries after gossipd acks block.
If it gets really far behind, then we restart, it could miss some. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
20a41fd798
commit
a4847b5af4
3 changed files with 8 additions and 4 deletions
|
@ -222,6 +222,10 @@ static void gossipd_new_blockheight_reply(struct subd *gossipd,
|
||||||
|
|
||||||
/* Now, finally update getinfo's blockheight */
|
/* Now, finally update getinfo's blockheight */
|
||||||
gossipd->ld->gossip_blockheight = ptr2int(blockheight);
|
gossipd->ld->gossip_blockheight = ptr2int(blockheight);
|
||||||
|
|
||||||
|
/* And use that to trim old entries in the UTXO set */
|
||||||
|
wallet_utxoset_prune(gossipd->ld->wallet,
|
||||||
|
gossipd->ld->gossip_blockheight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gossip_notify_new_block(struct lightningd *ld, u32 blockheight)
|
void gossip_notify_new_block(struct lightningd *ld, u32 blockheight)
|
||||||
|
|
|
@ -4198,7 +4198,7 @@ bool wallet_sanity_check(struct wallet *w)
|
||||||
/**
|
/**
|
||||||
* wallet_utxoset_prune -- Remove spent UTXO entries that are old
|
* wallet_utxoset_prune -- Remove spent UTXO entries that are old
|
||||||
*/
|
*/
|
||||||
static void wallet_utxoset_prune(struct wallet *w, const u32 blockheight)
|
void wallet_utxoset_prune(struct wallet *w, u32 blockheight)
|
||||||
{
|
{
|
||||||
struct db_stmt *stmt;
|
struct db_stmt *stmt;
|
||||||
|
|
||||||
|
@ -4236,9 +4236,6 @@ void wallet_block_add(struct wallet *w, struct block *b)
|
||||||
db_bind_null(stmt);
|
db_bind_null(stmt);
|
||||||
}
|
}
|
||||||
db_exec_prepared_v2(take(stmt));
|
db_exec_prepared_v2(take(stmt));
|
||||||
|
|
||||||
/* Now cleanup UTXOs that we don't care about anymore */
|
|
||||||
wallet_utxoset_prune(w, b->height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wallet_block_remove(struct wallet *w, struct block *b)
|
void wallet_block_remove(struct wallet *w, struct block *b)
|
||||||
|
|
|
@ -1135,6 +1135,9 @@ void wallet_utxoset_add(struct wallet *w,
|
||||||
const struct short_channel_id *
|
const struct short_channel_id *
|
||||||
wallet_utxoset_get_spent(const tal_t *ctx, struct wallet *w, u32 blockheight);
|
wallet_utxoset_get_spent(const tal_t *ctx, struct wallet *w, u32 blockheight);
|
||||||
|
|
||||||
|
/* Prune all UTXO entries spent (far) below this block height */
|
||||||
|
void wallet_utxoset_prune(struct wallet *w, u32 blockheight);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve all UTXO entries that were created at a given blockheight.
|
* Retrieve all UTXO entries that were created at a given blockheight.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue