}
}
+impl<A> SyncResponse<A> {
+ /// Returns true if the `SyncResponse` is empty.
+ pub fn is_empty(&self) -> bool {
+ self.tx_update.is_empty() && self.chain_update.is_none()
+ }
+}
+
/// Builds a [`FullScanRequest`].
///
/// Construct with [`FullScanRequest::builder`].
}
}
+impl<K, A> FullScanResponse<K, A> {
+ /// Returns true if the `FullScanResponse` is empty.
+ pub fn is_empty(&self) -> bool {
+ self.tx_update.is_empty()
+ && self.last_active_indices.is_empty()
+ && self.chain_update.is_none()
+ }
+}
+
struct KeychainSpkIter<'r, K> {
keychain: K,
spks: Option<&'r mut Box<dyn Iterator<Item = Indexed<ScriptBuf>> + Send>>,
}
}
+impl<A> TxUpdate<A> {
+ /// Returns true if the `TxUpdate` contains no elements in any of its fields.
+ pub fn is_empty(&self) -> bool {
+ self.txs.is_empty()
+ && self.txouts.is_empty()
+ && self.anchors.is_empty()
+ && self.seen_ats.is_empty()
+ && self.evicted_ats.is_empty()
+ }
+}
+
impl<A: Ord> TxUpdate<A> {
/// Transforms the [`TxUpdate`] to have `anchors` (`A`) of another type (`A2`).
///
--- /dev/null
+use bdk_core::spk_client::{FullScanResponse, SyncResponse};
+
+#[test]
+fn test_empty() {
+ assert!(
+ FullScanResponse::<(), ()>::default().is_empty(),
+ "Default `FullScanResponse` must be empty"
+ );
+ assert!(
+ SyncResponse::<()>::default().is_empty(),
+ "Default `SyncResponse` must be empty"
+ );
+}
--- /dev/null
+use bdk_core::TxUpdate;
+
+#[test]
+fn test_empty() {
+ assert!(
+ TxUpdate::<()>::default().is_empty(),
+ "Default `TxUpdate` must be empty"
+ );
+}