• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bitcoindevkit / bdk / 9523451493

14 Jun 2024 11:16PM CUT coverage: 83.312% (+0.2%) from 83.064%
9523451493

Pull #1473

github

web-flow
Merge d4393f912 into bc420923c
Pull Request #1473: Remove `persist` submodule

58 of 64 new or added lines in 5 files covered. (90.63%)

1 existing line in 1 file now uncovered.

11128 of 13357 relevant lines covered (83.31%)

17283.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.73
/crates/chain/src/changeset.rs
1
/// A changeset containing [`crate`] structures typically persisted together.
2
#[cfg(feature = "miniscript")]
3
#[derive(Debug, Clone, PartialEq)]
4
#[cfg_attr(
5
    feature = "serde",
6
    derive(crate::serde::Deserialize, crate::serde::Serialize),
12✔
7
    serde(
8
        crate = "crate::serde",
9
        bound(
10
            deserialize = "A: Ord + crate::serde::Deserialize<'de>, K: Ord + crate::serde::Deserialize<'de>",
11
            serialize = "A: Ord + crate::serde::Serialize, K: Ord + crate::serde::Serialize",
12
        ),
13
    )
14
)]
15
pub struct CombinedChangeSet<K, A> {
16
    /// Changes to the [`LocalChain`](crate::local_chain::LocalChain).
17
    pub chain: crate::local_chain::ChangeSet,
18
    /// Changes to [`IndexedTxGraph`](crate::indexed_tx_graph::IndexedTxGraph).
19
    pub indexed_tx_graph: crate::indexed_tx_graph::ChangeSet<A, crate::keychain::ChangeSet<K>>,
20
    /// Stores the network type of the transaction data.
21
    pub network: Option<bitcoin::Network>,
22
}
23

24
#[cfg(feature = "miniscript")]
25
impl<K, A> core::default::Default for CombinedChangeSet<K, A> {
26
    fn default() -> Self {
11,283✔
27
        Self {
11,283✔
28
            chain: core::default::Default::default(),
11,283✔
29
            indexed_tx_graph: core::default::Default::default(),
11,283✔
30
            network: None,
11,283✔
31
        }
11,283✔
32
    }
11,283✔
33
}
34

35
#[cfg(feature = "miniscript")]
36
impl<K: Ord, A: crate::Anchor> crate::Append for CombinedChangeSet<K, A> {
37
    fn append(&mut self, other: Self) {
11,161✔
38
        crate::Append::append(&mut self.chain, other.chain);
11,161✔
39
        crate::Append::append(&mut self.indexed_tx_graph, other.indexed_tx_graph);
11,161✔
40
        if other.network.is_some() {
11,161✔
41
            debug_assert!(
3✔
42
                self.network.is_none() || self.network == other.network,
3✔
NEW
43
                "network type must either be just introduced or remain the same"
×
44
            );
45
            self.network = other.network;
3✔
46
        }
11,158✔
47
    }
11,161✔
48

49
    fn is_empty(&self) -> bool {
2,487✔
50
        self.chain.is_empty() && self.indexed_tx_graph.is_empty() && self.network.is_none()
2,487✔
51
    }
2,487✔
52
}
53

54
#[cfg(feature = "miniscript")]
55
impl<K, A> From<crate::local_chain::ChangeSet> for CombinedChangeSet<K, A> {
56
    fn from(chain: crate::local_chain::ChangeSet) -> Self {
2,158✔
57
        Self {
2,158✔
58
            chain,
2,158✔
59
            ..Default::default()
2,158✔
60
        }
2,158✔
61
    }
2,158✔
62
}
63

64
#[cfg(feature = "miniscript")]
65
impl<K, A> From<crate::indexed_tx_graph::ChangeSet<A, crate::keychain::ChangeSet<K>>>
66
    for CombinedChangeSet<K, A>
67
{
68
    fn from(
5,860✔
69
        indexed_tx_graph: crate::indexed_tx_graph::ChangeSet<A, crate::keychain::ChangeSet<K>>,
5,860✔
70
    ) -> Self {
5,860✔
71
        Self {
5,860✔
72
            indexed_tx_graph,
5,860✔
73
            ..Default::default()
5,860✔
74
        }
5,860✔
75
    }
5,860✔
76
}
77

78
#[cfg(feature = "miniscript")]
79
impl<K, A> From<crate::keychain::ChangeSet<K>> for CombinedChangeSet<K, A> {
80
    fn from(indexer: crate::keychain::ChangeSet<K>) -> Self {
720✔
81
        Self {
720✔
82
            indexed_tx_graph: crate::indexed_tx_graph::ChangeSet {
720✔
83
                indexer,
720✔
84
                ..Default::default()
720✔
85
            },
720✔
86
            ..Default::default()
720✔
87
        }
720✔
88
    }
720✔
89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc