]> Untitled Git - bdk/commitdiff
feat(core)!: Remove redundant `SyncRequest` methods
author志宇 <hello@evanlinjin.me>
Fri, 14 Mar 2025 00:23:24 +0000 (11:23 +1100)
committer志宇 <hello@evanlinjin.me>
Fri, 14 Mar 2025 02:16:41 +0000 (13:16 +1100)
Methods `next_spk` and `iter_spks` are removed. These are superceded
with `next_spk_with_expected_txids` and `iter_spks_with_expected_txids`.

crates/core/src/spk_client.rs

index a82d24170dc26b44ad48513f8c486fa526556816..b6a8e0204e21a6a8f035204557ef115e92935324 100644 (file)
@@ -320,22 +320,14 @@ impl<I> SyncRequest<I> {
         self.chain_tip.clone()
     }
 
-    /// Advances the sync request and returns the next [`ScriptBuf`].
-    ///
-    /// Returns [`None`] when there are no more scripts remaining in the request.
-    pub fn next_spk(&mut self) -> Option<ScriptBuf> {
-        let (i, spk) = self.spks.pop_front()?;
-        self.spks_consumed += 1;
-        self._call_inspect(SyncItem::Spk(i, spk.as_script()));
-        Some(spk)
-    }
-
     /// Advances the sync request and returns the next [`ScriptBuf`] with corresponding [`Txid`]
     /// history.
     ///
     /// Returns [`None`] when there are no more scripts remaining in the request.
     pub fn next_spk_with_expected_txids(&mut self) -> Option<SpkWithExpectedTxids> {
-        let next_spk = self.next_spk()?;
+        let (i, next_spk) = self.spks.pop_front()?;
+        self.spks_consumed += 1;
+        self._call_inspect(SyncItem::Spk(i, next_spk.as_script()));
         let spk_history = self
             .spk_expected_txids
             .get(&next_spk)
@@ -367,11 +359,6 @@ impl<I> SyncRequest<I> {
         Some(outpoint)
     }
 
-    /// Iterate over [`ScriptBuf`]s contained in this request.
-    pub fn iter_spks(&mut self) -> impl ExactSizeIterator<Item = ScriptBuf> + '_ {
-        SyncIter::<I, ScriptBuf>::new(self)
-    }
-
     /// Iterate over [`ScriptBuf`]s with corresponding [`Txid`] histories contained in this request.
     pub fn iter_spks_with_expected_txids(
         &mut self,
@@ -605,19 +592,6 @@ impl<'r, I, Item> SyncIter<'r, I, Item> {
 
 impl<'r, I, Item> ExactSizeIterator for SyncIter<'r, I, Item> where SyncIter<'r, I, Item>: Iterator {}
 
-impl<I> Iterator for SyncIter<'_, I, ScriptBuf> {
-    type Item = ScriptBuf;
-
-    fn next(&mut self) -> Option<Self::Item> {
-        self.request.next_spk()
-    }
-
-    fn size_hint(&self) -> (usize, Option<usize>) {
-        let remaining = self.request.spks.len();
-        (remaining, Some(remaining))
-    }
-}
-
 impl<I> Iterator for SyncIter<'_, I, SpkWithExpectedTxids> {
     type Item = SpkWithExpectedTxids;