///
/// See also [`SyncRequest`].
#[must_use]
-#[derive(Debug)]
+#[derive(Debug, Clone, PartialEq)]
pub struct SyncResponse<A = ConfirmationBlockTime, D = BlockHash> {
/// Relevant transaction data discovered during the scan.
pub tx_update: crate::TxUpdate<A>,
}
}
-impl<A> SyncResponse<A> {
+impl<A, D> SyncResponse<A, D> {
/// Returns true if the `SyncResponse` is empty.
pub fn is_empty(&self) -> bool {
self.tx_update.is_empty() && self.chain_update.is_none()
///
/// See also [`FullScanRequest`].
#[must_use]
-#[derive(Debug)]
+#[derive(Debug, Clone, PartialEq)]
pub struct FullScanResponse<K, A = ConfirmationBlockTime, D = BlockHash> {
/// Relevant transaction data discovered during the scan.
pub tx_update: crate::TxUpdate<A>,
}
}
-impl<K, A> FullScanResponse<K, A> {
+impl<K, A, D> FullScanResponse<K, A, D> {
/// Returns true if the `FullScanResponse` is empty.
pub fn is_empty(&self) -> bool {
self.tx_update.is_empty()
///
/// The built-in chain-source crates (`bdk_electrum`, `bdk_esplora`, `bdk_bitcoind_rpc`) handle this
/// automatically. Transactions lacking temporal context are stored but ignored by canonicalization.
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct TxUpdate<A = ()> {
/// Full transactions. These are transactions that were determined to be relevant to the wallet
SyncResponse::<()>::default().is_empty(),
"Default `SyncResponse` must be empty"
);
+ // Custom checkpoint data type `D` must also support `is_empty()`
+ assert!(
+ FullScanResponse::<(), (), ()>::default().is_empty(),
+ "Default `FullScanResponse` with custom checkpoint type must be empty"
+ );
+ assert!(
+ SyncResponse::<(), ()>::default().is_empty(),
+ "Default `SyncResponse` with custom checkpoint type must be empty"
+ );
}
#[test]