chore(chain): relax miniscript
feature flag scope
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.
This commit is contained in:
parent
9e97ac0330
commit
36e82ec686
@ -50,7 +50,6 @@ pub use descriptor_ext::{DescriptorExt, DescriptorId};
|
|||||||
mod spk_iter;
|
mod spk_iter;
|
||||||
#[cfg(feature = "miniscript")]
|
#[cfg(feature = "miniscript")]
|
||||||
pub use spk_iter::*;
|
pub use spk_iter::*;
|
||||||
#[cfg(feature = "miniscript")]
|
|
||||||
pub mod persist;
|
pub mod persist;
|
||||||
pub mod spk_client;
|
pub mod spk_client;
|
||||||
|
|
||||||
|
@ -4,18 +4,16 @@
|
|||||||
//! The [`CombinedChangeSet`] type encapsulates a combination of [`crate`] structures that are
|
//! The [`CombinedChangeSet`] type encapsulates a combination of [`crate`] structures that are
|
||||||
//! typically persisted together.
|
//! typically persisted together.
|
||||||
|
|
||||||
use crate::{indexed_tx_graph, keychain, local_chain, Anchor, Append};
|
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use bitcoin::Network;
|
|
||||||
use core::convert::Infallible;
|
use core::convert::Infallible;
|
||||||
use core::default::Default;
|
|
||||||
use core::fmt::{Debug, Display};
|
use core::fmt::{Debug, Display};
|
||||||
|
|
||||||
/// A changeset containing [`crate`] structures typically persisted together.
|
/// A changeset containing [`crate`] structures typically persisted together.
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
#[cfg(feature = "miniscript")]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serde",
|
feature = "serde",
|
||||||
derive(crate::serde::Deserialize, crate::serde::Serialize),
|
derive(crate::serde::Deserialize, crate::serde::Serialize),
|
||||||
@ -28,28 +26,30 @@ use core::fmt::{Debug, Display};
|
|||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
pub struct CombinedChangeSet<K, A> {
|
pub struct CombinedChangeSet<K, A> {
|
||||||
/// Changes to the [`LocalChain`](local_chain::LocalChain).
|
/// Changes to the [`LocalChain`](crate::local_chain::LocalChain).
|
||||||
pub chain: local_chain::ChangeSet,
|
pub chain: crate::local_chain::ChangeSet,
|
||||||
/// Changes to [`IndexedTxGraph`](indexed_tx_graph::IndexedTxGraph).
|
/// Changes to [`IndexedTxGraph`](crate::indexed_tx_graph::IndexedTxGraph).
|
||||||
pub indexed_tx_graph: indexed_tx_graph::ChangeSet<A, keychain::ChangeSet<K>>,
|
pub indexed_tx_graph: crate::indexed_tx_graph::ChangeSet<A, crate::keychain::ChangeSet<K>>,
|
||||||
/// Stores the network type of the transaction data.
|
/// 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 {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
chain: Default::default(),
|
chain: core::default::Default::default(),
|
||||||
indexed_tx_graph: Default::default(),
|
indexed_tx_graph: core::default::Default::default(),
|
||||||
network: None,
|
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) {
|
fn append(&mut self, other: Self) {
|
||||||
Append::append(&mut self.chain, other.chain);
|
crate::Append::append(&mut self.chain, other.chain);
|
||||||
Append::append(&mut self.indexed_tx_graph, other.indexed_tx_graph);
|
crate::Append::append(&mut self.indexed_tx_graph, other.indexed_tx_graph);
|
||||||
if other.network.is_some() {
|
if other.network.is_some() {
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
self.network.is_none() || self.network == other.network,
|
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> {
|
#[cfg(feature = "miniscript")]
|
||||||
fn from(chain: local_chain::ChangeSet) -> Self {
|
impl<K, A> From<crate::local_chain::ChangeSet> for CombinedChangeSet<K, A> {
|
||||||
|
fn from(chain: crate::local_chain::ChangeSet) -> Self {
|
||||||
Self {
|
Self {
|
||||||
chain,
|
chain,
|
||||||
..Default::default()
|
..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>
|
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 {
|
Self {
|
||||||
indexed_tx_graph,
|
indexed_tx_graph,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -4,9 +4,9 @@ use crate::{
|
|||||||
collections::BTreeMap, keychain::Indexed, local_chain::CheckPoint,
|
collections::BTreeMap, keychain::Indexed, local_chain::CheckPoint,
|
||||||
ConfirmationTimeHeightAnchor, TxGraph,
|
ConfirmationTimeHeightAnchor, TxGraph,
|
||||||
};
|
};
|
||||||
use alloc::{boxed::Box, vec::Vec};
|
use alloc::boxed::Box;
|
||||||
use bitcoin::{OutPoint, Script, ScriptBuf, Txid};
|
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.
|
/// 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.
|
/// This consumes the [`SyncRequest`] and returns the updated one.
|
||||||
#[cfg(feature = "miniscript")]
|
#[cfg(feature = "miniscript")]
|
||||||
#[must_use]
|
#[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,
|
self,
|
||||||
index: &crate::keychain::KeychainTxOutIndex<K>,
|
index: &crate::keychain::KeychainTxOutIndex<K>,
|
||||||
spk_range: impl RangeBounds<K>,
|
spk_range: impl core::ops::RangeBounds<K>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
use alloc::borrow::ToOwned;
|
use alloc::borrow::ToOwned;
|
||||||
|
use alloc::vec::Vec;
|
||||||
self.chain_spks(
|
self.chain_spks(
|
||||||
index
|
index
|
||||||
.revealed_spks(spk_range)
|
.revealed_spks(spk_range)
|
||||||
@ -223,7 +224,7 @@ impl<K: Ord + Clone> FullScanRequest<K> {
|
|||||||
index: &crate::keychain::KeychainTxOutIndex<K>,
|
index: &crate::keychain::KeychainTxOutIndex<K>,
|
||||||
) -> Self
|
) -> Self
|
||||||
where
|
where
|
||||||
K: Debug,
|
K: core::fmt::Debug,
|
||||||
{
|
{
|
||||||
let mut req = Self::from_chain_tip(chain_tip);
|
let mut req = Self::from_chain_tip(chain_tip);
|
||||||
for (keychain, spks) in index.all_unbounded_spk_iters() {
|
for (keychain, spks) in index.all_unbounded_spk_iters() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user