Skip to content

Commit 9284767

Browse files
committed
docs(wallet): expand docs for apply_evicted_txs
1 parent 0eb4a9c commit 9284767

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

wallet/src/wallet/mod.rs

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2456,13 +2456,41 @@ impl Wallet {
24562456
self.stage.merge(indexed_graph_changeset.into());
24572457
}
24582458

2459-
/// Apply evictions of the given txids with their associated timestamps.
2459+
/// Apply evictions of the given transaction IDs with their associated timestamps.
24602460
///
2461-
/// This means that any pending unconfirmed tx in this set will no longer be canonical by
2462-
/// default. Note that an evicted tx can become canonical if it is later seen again or
2463-
/// observed on-chain.
2461+
/// This function is used to mark specific unconfirmed transactions as evicted from the mempool.
2462+
/// Eviction means that these transactions are not considered canonical by default, and will
2463+
/// no longer be part of the wallet's [`transactions`] set. This can happen for example when
2464+
/// a transaction is dropped from the mempool due to low fees or conflicts with another
2465+
/// transaction.
24642466
///
2465-
/// This stages the changes which need to be persisted.
2467+
/// Only transactions that are currently unconfirmed and canonical are considered for eviction.
2468+
/// Transactions that are not relevant to the wallet are ignored. Note that an evicted
2469+
/// transaction can become canonical again if it is later observed on-chain or seen in the
2470+
/// mempool with a higher priority (e.g., due to a fee bump).
2471+
///
2472+
/// ## Parameters
2473+
///
2474+
/// `evicted_txs`: An iterator of `(Txid, u64)` tuples, where:
2475+
/// - `Txid`: The transaction ID of the transaction to be evicted.
2476+
/// - `u64`: The timestamp indicating when the transaction was evicted from the mempool. This
2477+
/// will usually correspond to the time of the latest chain sync. See docs for
2478+
/// [`start_sync_with_revealed_spks`].
2479+
///
2480+
/// ## Notes
2481+
///
2482+
/// - This function is particularly useful when syncing with a blockchain backend that provides
2483+
/// mempool eviction notifications.
2484+
/// - The changes are staged in the wallet's internal state and must be persisted to ensure they
2485+
/// are retained across wallet restarts. Use [`Wallet::take_staged`] to retrieve the staged
2486+
/// changes and persist them to your database of choice.
2487+
/// - Evicted transactions are removed from the wallet's canonical transaction set, but the data
2488+
/// remains in the wallet's internal transaction graph for historical purposes.
2489+
/// - Ensure that the timestamps provided are accurate and monotonically increasing, as they
2490+
/// influence the wallet's canonicalization logic.
2491+
///
2492+
/// [`transactions`]: Wallet::transactions
2493+
/// [`start_sync_with_revealed_spks`]: Wallet::start_sync_with_revealed_spks
24662494
pub fn apply_evicted_txs(&mut self, evicted_txs: impl IntoIterator<Item = (Txid, u64)>) {
24672495
let chain = &self.chain;
24682496
let canon_txids: Vec<Txid> = self

0 commit comments

Comments
 (0)