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

bitcoindevkit / bdk / 9740859344

01 Jul 2024 08:30AM UTC coverage: 83.173% (+0.1%) from 83.029%
9740859344

Pull #1478

github

web-flow
Merge eb10e4379 into 22368ab7b
Pull Request #1478: Make `bdk_esplora` more modular

351 of 415 new or added lines in 2 files covered. (84.58%)

213 existing lines in 7 files now uncovered.

11141 of 13395 relevant lines covered (83.17%)

16583.83 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
#[derive(Debug, Clone, PartialEq)]
3
#[cfg_attr(
4
    feature = "serde",
5
    derive(crate::serde::Deserialize, crate::serde::Serialize),
12✔
6
    serde(
7
        crate = "crate::serde",
8
        bound(
9
            deserialize = "A: Ord + crate::serde::Deserialize<'de>, K: Ord + crate::serde::Deserialize<'de>",
10
            serialize = "A: Ord + crate::serde::Serialize, K: Ord + crate::serde::Serialize",
11
        ),
12
    )
13
)]
14
pub struct CombinedChangeSet<K, A> {
15
    /// Changes to the [`LocalChain`](crate::local_chain::LocalChain).
16
    pub chain: crate::local_chain::ChangeSet,
17
    /// Changes to [`IndexedTxGraph`](crate::indexed_tx_graph::IndexedTxGraph).
18
    pub indexed_tx_graph: crate::indexed_tx_graph::ChangeSet<A, crate::keychain::ChangeSet<K>>,
19
    /// Stores the network type of the transaction data.
20
    pub network: Option<bitcoin::Network>,
21
}
22

23
impl<K, A> core::default::Default for CombinedChangeSet<K, A> {
24
    fn default() -> Self {
11,211✔
25
        Self {
11,211✔
26
            chain: core::default::Default::default(),
11,211✔
27
            indexed_tx_graph: core::default::Default::default(),
11,211✔
28
            network: None,
11,211✔
29
        }
11,211✔
30
    }
11,211✔
31
}
32

33
impl<K: Ord, A: crate::Anchor> crate::Append for CombinedChangeSet<K, A> {
34
    fn append(&mut self, other: Self) {
11,089✔
35
        crate::Append::append(&mut self.chain, other.chain);
11,089✔
36
        crate::Append::append(&mut self.indexed_tx_graph, other.indexed_tx_graph);
11,089✔
37
        if other.network.is_some() {
11,089✔
38
            debug_assert!(
3✔
39
                self.network.is_none() || self.network == other.network,
3✔
UNCOV
40
                "network type must either be just introduced or remain the same"
×
41
            );
42
            self.network = other.network;
3✔
43
        }
11,086✔
44
    }
11,089✔
45

46
    fn is_empty(&self) -> bool {
2,471✔
47
        self.chain.is_empty() && self.indexed_tx_graph.is_empty() && self.network.is_none()
2,471✔
48
    }
2,471✔
49
}
50

51
impl<K, A> From<crate::local_chain::ChangeSet> for CombinedChangeSet<K, A> {
52
    fn from(chain: crate::local_chain::ChangeSet) -> Self {
2,142✔
53
        Self {
2,142✔
54
            chain,
2,142✔
55
            ..Default::default()
2,142✔
56
        }
2,142✔
57
    }
2,142✔
58
}
59

60
impl<K, A> From<crate::indexed_tx_graph::ChangeSet<A, crate::keychain::ChangeSet<K>>>
61
    for CombinedChangeSet<K, A>
62
{
63
    fn from(
5,820✔
64
        indexed_tx_graph: crate::indexed_tx_graph::ChangeSet<A, crate::keychain::ChangeSet<K>>,
5,820✔
65
    ) -> Self {
5,820✔
66
        Self {
5,820✔
67
            indexed_tx_graph,
5,820✔
68
            ..Default::default()
5,820✔
69
        }
5,820✔
70
    }
5,820✔
71
}
72

73
impl<K, A> From<crate::keychain::ChangeSet<K>> for CombinedChangeSet<K, A> {
74
    fn from(indexer: crate::keychain::ChangeSet<K>) -> Self {
720✔
75
        Self {
720✔
76
            indexed_tx_graph: crate::indexed_tx_graph::ChangeSet {
720✔
77
                indexer,
720✔
78
                ..Default::default()
720✔
79
            },
720✔
80
            ..Default::default()
720✔
81
        }
720✔
82
    }
720✔
83
}
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