Skip to content

Commit 12b00e0

Browse files
committed
feat(wallet): Add method apply_evicted_txs
1 parent a247215 commit 12b00e0

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

wallet/src/wallet/mod.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,6 +2367,35 @@ impl Wallet {
23672367
self.stage.merge(indexed_graph_changeset.into());
23682368
}
23692369

2370+
/// Apply evictions of the given txids with their associated timestamps.
2371+
///
2372+
/// This means that any pending unconfirmed tx in this set will no longer be canonical by
2373+
/// default. Note that an evicted tx can become canonical if it is later seen again or
2374+
/// observed on-chain.
2375+
///
2376+
/// This stages the changes which need to be persisted.
2377+
pub fn apply_evicted_txs(&mut self, evicted_txs: impl IntoIterator<Item = (Txid, u64)>) {
2378+
let chain = &self.chain;
2379+
let canon_txids: Vec<Txid> = self
2380+
.indexed_graph
2381+
.graph()
2382+
.list_canonical_txs(
2383+
chain,
2384+
chain.tip().block_id(),
2385+
CanonicalizationParams::default(),
2386+
)
2387+
.map(|c| c.tx_node.txid)
2388+
.collect();
2389+
2390+
let changeset = self.indexed_graph.batch_insert_relevant_evicted_at(
2391+
evicted_txs
2392+
.into_iter()
2393+
.filter(|(txid, _)| canon_txids.contains(txid)),
2394+
);
2395+
2396+
self.stage.merge(changeset.into());
2397+
}
2398+
23702399
/// Used internally to ensure that all methods requiring a [`KeychainKind`] will use a
23712400
/// keychain with an associated descriptor. For example in case the wallet was created
23722401
/// with only one keychain, passing [`KeychainKind::Internal`] here will instead return

0 commit comments

Comments
 (0)