-
Notifications
You must be signed in to change notification settings - Fork 31
docs(wallet): expand docs for apply_evicted_txs
#270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ValuedMammal
wants to merge
2
commits into
bitcoindevkit:master
Choose a base branch
from
ValuedMammal:doc/apply-evicted-txs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2456,13 +2456,41 @@ impl Wallet { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
self.stage.merge(indexed_graph_changeset.into()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// Apply evictions of the given txids with their associated timestamps. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// Apply evictions of the given transaction IDs with their associated timestamps. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// This means that any pending unconfirmed tx in this set will no longer be canonical by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// default. Note that an evicted tx can become canonical if it is later seen again or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// observed on-chain. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// This function is used to mark specific unconfirmed transactions as evicted from the mempool. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// Eviction means that these transactions are not considered canonical by default, and will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// no longer be part of the wallet's [`transactions`] set. This can happen for example when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// a transaction is dropped from the mempool due to low fees or conflicts with another | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// transaction. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// This stages the changes which need to be persisted. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// Only transactions that are currently unconfirmed and canonical are considered for eviction. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// Transactions that are not relevant to the wallet are ignored. Note that an evicted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// transaction can become canonical again if it is later observed on-chain or seen in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// mempool with a higher priority (e.g., due to a fee bump). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// ## Parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// `evicted_txs`: An iterator of `(Txid, u64)` tuples, where: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// - `Txid`: The transaction ID of the transaction to be evicted. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// - `u64`: The timestamp indicating when the transaction was evicted from the mempool. This | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// will usually correspond to the time of the latest chain sync. See docs for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// [`start_sync_with_revealed_spks`]. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// ## Notes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// - This function is particularly useful when syncing with a blockchain backend that provides | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// mempool eviction notifications. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// - The changes are staged in the wallet's internal state and must be persisted to ensure they | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// are retained across wallet restarts. Use [`Wallet::take_staged`] to retrieve the staged | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// changes and persist them to your database of choice. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// - Evicted transactions are removed from the wallet's canonical transaction set, but the data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// remains in the wallet's internal transaction graph for historical purposes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// - Ensure that the timestamps provided are accurate and monotonically increasing, as they | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// influence the wallet's canonicalization logic. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// [`transactions`]: Wallet::transactions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// [`start_sync_with_revealed_spks`]: Wallet::start_sync_with_revealed_spks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be great to also include an example here:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pub fn apply_evicted_txs(&mut self, evicted_txs: impl IntoIterator<Item = (Txid, u64)>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let chain = &self.chain; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let canon_txids: Vec<Txid> = self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me if or when a user needs to use this function. Don't the bdk_* chain clients already evict tx when they notice it missing from the mempool?