]> Untitled Git - bdk/commitdiff
chore(chain): relax `miniscript` feature flag scope
author志宇 <hello@evanlinjin.me>
Thu, 13 Jun 2024 06:13:46 +0000 (14:13 +0800)
committerSteve Myers <steve@notmandatory.org>
Thu, 13 Jun 2024 17:56:30 +0000 (12:56 -0500)
Still enable the `persist` submodule without `miniscript` feature flag.
Only disable `CombinedChangeSet`.

Also stop `cargo clippy` from complaining about unused imports when
`miniscript` is disabled.

crates/chain/src/lib.rs
crates/chain/src/persist.rs
crates/chain/src/spk_client.rs

index 6ce94254b9ed24b388c72b57a23950c081bca738..7a5036a2f0926569ead6d882ea3f5c6e6b1b9c94 100644 (file)
@@ -50,7 +50,6 @@ pub use descriptor_ext::{DescriptorExt, DescriptorId};
 mod spk_iter;
 #[cfg(feature = "miniscript")]
 pub use spk_iter::*;
-#[cfg(feature = "miniscript")]
 pub mod persist;
 pub mod spk_client;
 
index 49973c163d419f54cb9bd589ef4daa066fbb4395..2daf1585c845ccc3ce9145eb142df2d50d6d6692 100644 (file)
@@ -4,18 +4,16 @@
 //! The [`CombinedChangeSet`] type encapsulates a combination of [`crate`] structures that are
 //! typically persisted together.
 
-use crate::{indexed_tx_graph, keychain, local_chain, Anchor, Append};
 #[cfg(feature = "async")]
 use alloc::boxed::Box;
 #[cfg(feature = "async")]
 use async_trait::async_trait;
-use bitcoin::Network;
 use core::convert::Infallible;
-use core::default::Default;
 use core::fmt::{Debug, Display};
 
 /// A changeset containing [`crate`] structures typically persisted together.
 #[derive(Debug, Clone, PartialEq)]
+#[cfg(feature = "miniscript")]
 #[cfg_attr(
     feature = "serde",
     derive(crate::serde::Deserialize, crate::serde::Serialize),
@@ -28,28 +26,30 @@ use core::fmt::{Debug, Display};
     )
 )]
 pub struct CombinedChangeSet<K, A> {
-    /// Changes to the [`LocalChain`](local_chain::LocalChain).
-    pub chain: local_chain::ChangeSet,
-    /// Changes to [`IndexedTxGraph`](indexed_tx_graph::IndexedTxGraph).
-    pub indexed_tx_graph: indexed_tx_graph::ChangeSet<A, keychain::ChangeSet<K>>,
+    /// Changes to the [`LocalChain`](crate::local_chain::LocalChain).
+    pub chain: crate::local_chain::ChangeSet,
+    /// Changes to [`IndexedTxGraph`](crate::indexed_tx_graph::IndexedTxGraph).
+    pub indexed_tx_graph: crate::indexed_tx_graph::ChangeSet<A, crate::keychain::ChangeSet<K>>,
     /// Stores the network type of the transaction data.
-    pub network: Option<Network>,
+    pub network: Option<bitcoin::Network>,
 }
 
-impl<K, A> Default for CombinedChangeSet<K, A> {
+#[cfg(feature = "miniscript")]
+impl<K, A> core::default::Default for CombinedChangeSet<K, A> {
     fn default() -> Self {
         Self {
-            chain: Default::default(),
-            indexed_tx_graph: Default::default(),
+            chain: core::default::Default::default(),
+            indexed_tx_graph: core::default::Default::default(),
             network: None,
         }
     }
 }
 
-impl<K: Ord, A: Anchor> Append for CombinedChangeSet<K, A> {
+#[cfg(feature = "miniscript")]
+impl<K: Ord, A: crate::Anchor> crate::Append for CombinedChangeSet<K, A> {
     fn append(&mut self, other: Self) {
-        Append::append(&mut self.chain, other.chain);
-        Append::append(&mut self.indexed_tx_graph, other.indexed_tx_graph);
+        crate::Append::append(&mut self.chain, other.chain);
+        crate::Append::append(&mut self.indexed_tx_graph, other.indexed_tx_graph);
         if other.network.is_some() {
             debug_assert!(
                 self.network.is_none() || self.network == other.network,
@@ -64,8 +64,9 @@ impl<K: Ord, A: Anchor> Append for CombinedChangeSet<K, A> {
     }
 }
 
-impl<K, A> From<local_chain::ChangeSet> for CombinedChangeSet<K, A> {
-    fn from(chain: local_chain::ChangeSet) -> Self {
+#[cfg(feature = "miniscript")]
+impl<K, A> From<crate::local_chain::ChangeSet> for CombinedChangeSet<K, A> {
+    fn from(chain: crate::local_chain::ChangeSet) -> Self {
         Self {
             chain,
             ..Default::default()
@@ -73,10 +74,13 @@ impl<K, A> From<local_chain::ChangeSet> for CombinedChangeSet<K, A> {
     }
 }
 
-impl<K, A> From<indexed_tx_graph::ChangeSet<A, keychain::ChangeSet<K>>>
+#[cfg(feature = "miniscript")]
+impl<K, A> From<crate::indexed_tx_graph::ChangeSet<A, crate::keychain::ChangeSet<K>>>
     for CombinedChangeSet<K, A>
 {
-    fn from(indexed_tx_graph: indexed_tx_graph::ChangeSet<A, keychain::ChangeSet<K>>) -> Self {
+    fn from(
+        indexed_tx_graph: crate::indexed_tx_graph::ChangeSet<A, crate::keychain::ChangeSet<K>>,
+    ) -> Self {
         Self {
             indexed_tx_graph,
             ..Default::default()
index 3cb87a407eabfeee401378ef402a9bd489639965..24bd9b4a7fa0b3971fe48d516c2340fdd5cbca10 100644 (file)
@@ -4,9 +4,9 @@ use crate::{
     collections::BTreeMap, keychain::Indexed, local_chain::CheckPoint,
     ConfirmationTimeHeightAnchor, TxGraph,
 };
-use alloc::{boxed::Box, vec::Vec};
+use alloc::boxed::Box;
 use bitcoin::{OutPoint, Script, ScriptBuf, Txid};
-use core::{fmt::Debug, marker::PhantomData, ops::RangeBounds};
+use core::marker::PhantomData;
 
 /// Data required to perform a spk-based blockchain client sync.
 ///
@@ -158,12 +158,13 @@ impl SyncRequest {
     /// This consumes the [`SyncRequest`] and returns the updated one.
     #[cfg(feature = "miniscript")]
     #[must_use]
-    pub fn populate_with_revealed_spks<K: Clone + Ord + Debug + Send + Sync>(
+    pub fn populate_with_revealed_spks<K: Clone + Ord + core::fmt::Debug + Send + Sync>(
         self,
         index: &crate::keychain::KeychainTxOutIndex<K>,
-        spk_range: impl RangeBounds<K>,
+        spk_range: impl core::ops::RangeBounds<K>,
     ) -> Self {
         use alloc::borrow::ToOwned;
+        use alloc::vec::Vec;
         self.chain_spks(
             index
                 .revealed_spks(spk_range)
@@ -223,7 +224,7 @@ impl<K: Ord + Clone> FullScanRequest<K> {
         index: &crate::keychain::KeychainTxOutIndex<K>,
     ) -> Self
     where
-        K: Debug,
+        K: core::fmt::Debug,
     {
         let mut req = Self::from_chain_tip(chain_tip);
         for (keychain, spks) in index.all_unbounded_spk_iters() {