Skip to content

Commit

Permalink
refactor(chain): SyncRequestBuilderExt::check_for_missing_txs
Browse files Browse the repository at this point in the history
Rename `SyncRequestBuilderExt::check_unconfirmed_statuses` to
`SyncRequestBuilderExt::check_for_missing_txs` and update docs.
  • Loading branch information
evanlinjin authored and LagginTimes committed Jan 27, 2025
1 parent d75fc25 commit bbd6340
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
17 changes: 10 additions & 7 deletions crates/chain/src/indexer/keychain_txout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,12 +882,15 @@ pub trait SyncRequestBuilderExt<K> {
/// Add [`Script`](bitcoin::Script)s that are revealed by the `indexer` but currently unused.
fn unused_spks_from_indexer(self, indexer: &KeychainTxOutIndex<K>) -> Self;

/// Add unconfirmed txids and their associated spks.
///
/// We expect that the chain source should include these txids in their spk histories. If not,
/// the transaction has been evicted for some reason and we will inform the receiving
/// structures in the response.
fn check_unconfirmed_statuses<A, C>(
/// Add txids of unconfirmed transactions and their associated spks to the request to check
/// whether they are missing from the mempool.
///
/// We expect that the chain source should include these txids in their spk history response. If
/// not, it means the transaction has been evicted from the mempool. The chain
/// source crate should include the missing transaction's txid in
/// [`TxUpdate::missing`](bdk_core::TxUpdate::missing) of
/// [`SyncResponse`](bdk_core::spk_client::SyncResponse).
fn check_for_missing_txs<A, C>(
self,
indexer: &KeychainTxOutIndex<K>,
canonical_iter: CanonicalIter<A, C>,
Expand All @@ -909,7 +912,7 @@ impl<K: Clone + Ord + core::fmt::Debug> SyncRequestBuilderExt<K> for SyncRequest
self.spks_with_indexes(indexer.unused_spks())
}

fn check_unconfirmed_statuses<A, C>(
fn check_for_missing_txs<A, C>(
self,
indexer: &KeychainTxOutIndex<K>,
canonical_iter: CanonicalIter<A, C>,
Expand Down
4 changes: 2 additions & 2 deletions crates/electrum/tests/test_electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub fn detect_receive_tx_cancel() -> anyhow::Result<()> {
let sync_request = SyncRequest::builder()
.chain_tip(chain.tip())
.revealed_spks_from_indexer(&graph.index, ..)
.check_unconfirmed_statuses(
.check_for_missing_txs(
&graph.index,
graph.graph().canonical_iter(&chain, chain.tip().block_id()),
);
Expand Down Expand Up @@ -163,7 +163,7 @@ pub fn detect_receive_tx_cancel() -> anyhow::Result<()> {
let sync_request = SyncRequest::builder()
.chain_tip(chain.tip())
.revealed_spks_from_indexer(&graph.index, ..)
.check_unconfirmed_statuses(
.check_for_missing_txs(
&graph.index,
graph.graph().canonical_iter(&chain, chain.tip().block_id()),
);
Expand Down
4 changes: 2 additions & 2 deletions crates/esplora/tests/async_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub async fn detect_receive_tx_cancel() -> anyhow::Result<()> {
let sync_request = SyncRequest::builder()
.chain_tip(chain.tip())
.revealed_spks_from_indexer(&graph.index, ..)
.check_unconfirmed_statuses(
.check_for_missing_txs(
&graph.index,
graph.graph().canonical_iter(&chain, chain.tip().block_id()),
);
Expand Down Expand Up @@ -122,7 +122,7 @@ pub async fn detect_receive_tx_cancel() -> anyhow::Result<()> {
let sync_request = SyncRequest::builder()
.chain_tip(chain.tip())
.revealed_spks_from_indexer(&graph.index, ..)
.check_unconfirmed_statuses(
.check_for_missing_txs(
&graph.index,
graph.graph().canonical_iter(&chain, chain.tip().block_id()),
);
Expand Down
4 changes: 2 additions & 2 deletions crates/esplora/tests/blocking_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub fn detect_receive_tx_cancel() -> anyhow::Result<()> {
let sync_request = SyncRequest::builder()
.chain_tip(chain.tip())
.revealed_spks_from_indexer(&graph.index, ..)
.check_unconfirmed_statuses(
.check_for_missing_txs(
&graph.index,
graph.graph().canonical_iter(&chain, chain.tip().block_id()),
);
Expand Down Expand Up @@ -122,7 +122,7 @@ pub fn detect_receive_tx_cancel() -> anyhow::Result<()> {
let sync_request = SyncRequest::builder()
.chain_tip(chain.tip())
.revealed_spks_from_indexer(&graph.index, ..)
.check_unconfirmed_statuses(
.check_for_missing_txs(
&graph.index,
graph.graph().canonical_iter(&chain, chain.tip().block_id()),
);
Expand Down

0 comments on commit bbd6340

Please sign in to comment.