From: 志宇 Date: Fri, 14 Mar 2025 00:23:24 +0000 (+1100) Subject: feat(core)!: Remove redundant `SyncRequest` methods X-Git-Tag: wallet-1.2.0~7^2~1 X-Git-Url: http://internal-gitweb-vhost/?a=commitdiff_plain;h=1f8fc173b6aeddbc81a8301346502f9a923554ce;p=bdk feat(core)!: Remove redundant `SyncRequest` methods Methods `next_spk` and `iter_spks` are removed. These are superceded with `next_spk_with_expected_txids` and `iter_spks_with_expected_txids`. --- diff --git a/crates/core/src/spk_client.rs b/crates/core/src/spk_client.rs index a82d2417..b6a8e020 100644 --- a/crates/core/src/spk_client.rs +++ b/crates/core/src/spk_client.rs @@ -320,22 +320,14 @@ impl SyncRequest { 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 { - 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 { - 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 SyncRequest { Some(outpoint) } - /// Iterate over [`ScriptBuf`]s contained in this request. - pub fn iter_spks(&mut self) -> impl ExactSizeIterator + '_ { - SyncIter::::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 Iterator for SyncIter<'_, I, ScriptBuf> { - type Item = ScriptBuf; - - fn next(&mut self) -> Option { - self.request.next_spk() - } - - fn size_hint(&self) -> (usize, Option) { - let remaining = self.request.spks.len(); - (remaining, Some(remaining)) - } -} - impl Iterator for SyncIter<'_, I, SpkWithExpectedTxids> { type Item = SpkWithExpectedTxids;