@@ -89,11 +89,11 @@ impl SyncProgress {
89
89
90
90
/// Builds a [`SyncRequest`].
91
91
#[ must_use]
92
- pub struct SyncRequestBuilder < SpkLabel = ( ) > {
93
- inner : SyncRequest < SpkLabel > ,
92
+ pub struct SyncRequestBuilder < I = ( ) > {
93
+ inner : SyncRequest < I > ,
94
94
}
95
95
96
- impl < SpkLabel > Default for SyncRequestBuilder < SpkLabel > {
96
+ impl < I > Default for SyncRequestBuilder < I > {
97
97
fn default ( ) -> Self {
98
98
Self {
99
99
inner : Default :: default ( ) ,
@@ -110,26 +110,26 @@ impl<K: Clone + Ord + core::fmt::Debug + Send + Sync> SyncRequestBuilder<(K, u32
110
110
indexer : & crate :: indexer:: keychain_txout:: KeychainTxOutIndex < K > ,
111
111
spk_range : impl core:: ops:: RangeBounds < K > ,
112
112
) -> Self {
113
- self . spks_with_labels ( indexer. revealed_spks ( spk_range) )
113
+ self . spks_with_indexes ( indexer. revealed_spks ( spk_range) )
114
114
}
115
115
116
116
/// Add [`Script`]s that are revealed by the `indexer` but currently unused.
117
117
pub fn unused_spks_from_indexer (
118
118
self ,
119
119
indexer : & crate :: indexer:: keychain_txout:: KeychainTxOutIndex < K > ,
120
120
) -> Self {
121
- self . spks_with_labels ( indexer. unused_spks ( ) )
121
+ self . spks_with_indexes ( indexer. unused_spks ( ) )
122
122
}
123
123
}
124
124
125
125
impl SyncRequestBuilder < ( ) > {
126
126
/// Add [`Script`]s that will be synced against.
127
127
pub fn spks ( self , spks : impl IntoIterator < Item = ScriptBuf > ) -> Self {
128
- self . spks_with_labels ( spks. into_iter ( ) . map ( |spk| ( ( ) , spk) ) )
128
+ self . spks_with_indexes ( spks. into_iter ( ) . map ( |spk| ( ( ) , spk) ) )
129
129
}
130
130
}
131
131
132
- impl < SpkLabel > SyncRequestBuilder < SpkLabel > {
132
+ impl < I > SyncRequestBuilder < I > {
133
133
/// Set the initial chain tip for the sync request.
134
134
///
135
135
/// This is used to update [`LocalChain`](crate::local_chain::LocalChain).
@@ -138,7 +138,7 @@ impl<SpkLabel> SyncRequestBuilder<SpkLabel> {
138
138
self
139
139
}
140
140
141
- /// Add [`Script`]s coupled with an associated label that will be synced against.
141
+ /// Add [`Script`]s coupled with associated indexes that will be synced against.
142
142
///
143
143
/// # Example
144
144
///
@@ -158,28 +158,25 @@ impl<SpkLabel> SyncRequestBuilder<SpkLabel> {
158
158
///
159
159
/// /* Assume that the caller does more mutations to the `indexer` here... */
160
160
///
161
- /// // Reveal spks for "descriptor_a", then build a sync request. Each spk will be labelled with
161
+ /// // Reveal spks for "descriptor_a", then build a sync request. Each spk will be indexed with
162
162
/// // `u32`, which represents the derivation index of the associated spk from "descriptor_a".
163
163
/// let (newly_revealed_spks, _changeset) = indexer
164
164
/// .reveal_to_target("descriptor_a", 21)
165
165
/// .expect("keychain must exist");
166
166
/// let _request = SyncRequest::builder()
167
- /// .spks_with_labels (newly_revealed_spks)
167
+ /// .spks_with_indexes (newly_revealed_spks)
168
168
/// .build();
169
169
///
170
170
/// // Sync all revealed spks in the indexer. This time, spks may be derived from different
171
- /// // keychains. Each spk will be labelled with `(&'static str, u32)` where `&'static str` is
171
+ /// // keychains. Each spk will be indexed with `(&'static str, u32)` where `&'static str` is
172
172
/// // the keychain identifier and `u32` is the derivation index.
173
173
/// let all_revealed_spks = indexer.revealed_spks(..);
174
174
/// let _request = SyncRequest::builder()
175
- /// .spks_with_labels (all_revealed_spks)
175
+ /// .spks_with_indexes (all_revealed_spks)
176
176
/// .build();
177
177
/// # Ok::<_, bdk_chain::keychain_txout::InsertDescriptorError<_>>(())
178
178
/// ```
179
- pub fn spks_with_labels (
180
- mut self ,
181
- spks : impl IntoIterator < Item = ( SpkLabel , ScriptBuf ) > ,
182
- ) -> Self {
179
+ pub fn spks_with_indexes ( mut self , spks : impl IntoIterator < Item = ( I , ScriptBuf ) > ) -> Self {
183
180
self . inner . spks . extend ( spks) ;
184
181
self
185
182
}
@@ -199,14 +196,14 @@ impl<SpkLabel> SyncRequestBuilder<SpkLabel> {
199
196
/// Set the closure that will inspect every sync item visited.
200
197
pub fn inspect < F > ( mut self , inspect : F ) -> Self
201
198
where
202
- F : FnMut ( SyncItem < SpkLabel > , SyncProgress ) + Send + ' static ,
199
+ F : FnMut ( SyncItem < I > , SyncProgress ) + Send + ' static ,
203
200
{
204
201
self . inner . inspect = Box :: new ( inspect) ;
205
202
self
206
203
}
207
204
208
205
/// Build the [`SyncRequest`].
209
- pub fn build ( self ) -> SyncRequest < SpkLabel > {
206
+ pub fn build ( self ) -> SyncRequest < I > {
210
207
self . inner
211
208
}
212
209
}
0 commit comments