Skip to content

Commit 2c37d06

Browse files
committed
refactor(chain): SyncRequestBuilderExt::check_for_missing_txs
Rename `SyncRequestBuilderExt::check_unconfirmed_statuses` to `SyncRequestBuilderExt::check_for_missing_txs` and update docs.
1 parent 2e31bc7 commit 2c37d06

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

crates/chain/src/indexer/keychain_txout.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -882,12 +882,15 @@ pub trait SyncRequestBuilderExt<K> {
882882
/// Add [`Script`](bitcoin::Script)s that are revealed by the `indexer` but currently unused.
883883
fn unused_spks_from_indexer(self, indexer: &KeychainTxOutIndex<K>) -> Self;
884884

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

912-
fn check_unconfirmed_statuses<A, C>(
915+
fn check_for_missing_txs<A, C>(
913916
self,
914917
indexer: &KeychainTxOutIndex<K>,
915918
canonical_iter: CanonicalIter<A, C>,

crates/electrum/tests/test_electrum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub fn detect_receive_tx_cancel() -> anyhow::Result<()> {
135135
let sync_request = SyncRequest::builder()
136136
.chain_tip(chain.tip())
137137
.revealed_spks_from_indexer(&graph.index, ..)
138-
.check_unconfirmed_statuses(
138+
.check_for_missing_txs(
139139
&graph.index,
140140
graph.graph().canonical_iter(&chain, chain.tip().block_id()),
141141
);
@@ -163,7 +163,7 @@ pub fn detect_receive_tx_cancel() -> anyhow::Result<()> {
163163
let sync_request = SyncRequest::builder()
164164
.chain_tip(chain.tip())
165165
.revealed_spks_from_indexer(&graph.index, ..)
166-
.check_unconfirmed_statuses(
166+
.check_for_missing_txs(
167167
&graph.index,
168168
graph.graph().canonical_iter(&chain, chain.tip().block_id()),
169169
);

crates/esplora/tests/async_ext.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub async fn detect_receive_tx_cancel() -> anyhow::Result<()> {
9494
let sync_request = SyncRequest::builder()
9595
.chain_tip(chain.tip())
9696
.revealed_spks_from_indexer(&graph.index, ..)
97-
.check_unconfirmed_statuses(
97+
.check_for_missing_txs(
9898
&graph.index,
9999
graph.graph().canonical_iter(&chain, chain.tip().block_id()),
100100
);
@@ -122,7 +122,7 @@ pub async fn detect_receive_tx_cancel() -> anyhow::Result<()> {
122122
let sync_request = SyncRequest::builder()
123123
.chain_tip(chain.tip())
124124
.revealed_spks_from_indexer(&graph.index, ..)
125-
.check_unconfirmed_statuses(
125+
.check_for_missing_txs(
126126
&graph.index,
127127
graph.graph().canonical_iter(&chain, chain.tip().block_id()),
128128
);

crates/esplora/tests/blocking_ext.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub fn detect_receive_tx_cancel() -> anyhow::Result<()> {
9494
let sync_request = SyncRequest::builder()
9595
.chain_tip(chain.tip())
9696
.revealed_spks_from_indexer(&graph.index, ..)
97-
.check_unconfirmed_statuses(
97+
.check_for_missing_txs(
9898
&graph.index,
9999
graph.graph().canonical_iter(&chain, chain.tip().block_id()),
100100
);
@@ -122,7 +122,7 @@ pub fn detect_receive_tx_cancel() -> anyhow::Result<()> {
122122
let sync_request = SyncRequest::builder()
123123
.chain_tip(chain.tip())
124124
.revealed_spks_from_indexer(&graph.index, ..)
125-
.check_unconfirmed_statuses(
125+
.check_for_missing_txs(
126126
&graph.index,
127127
graph.graph().canonical_iter(&chain, chain.tip().block_id()),
128128
);

0 commit comments

Comments
 (0)