|
40 | 40 | //! # use bdk_chain::example_utils::*; |
41 | 41 | //! # use bitcoin::Transaction; |
42 | 42 | //! # let tx_a = tx_from_hex(RAW_TX_1); |
43 | | -//! let mut graph: TxGraph = TxGraph::default(); |
44 | | -//! let mut another_graph: TxGraph = TxGraph::default(); |
| 43 | +//! let mut tx_graph: TxGraph = TxGraph::default(); |
45 | 44 | //! |
46 | 45 | //! // insert a transaction |
47 | | -//! let changeset = graph.insert_tx(tx_a); |
| 46 | +//! let changeset = tx_graph.insert_tx(tx_a); |
| 47 | +//! |
| 48 | +//! // We can restore the state of the `tx_graph` by applying all |
| 49 | +//! // the changesets obtained by mutating the original (the order doesn't matter). |
| 50 | +//! let mut restored_tx_graph: TxGraph = TxGraph::default(); |
| 51 | +//! restored_tx_graph.apply_changeset(changeset); |
48 | 52 | //! |
49 | | -//! // the resulting changeset can be applied to another tx graph |
50 | | -//! another_graph.apply_changeset(changeset); |
| 53 | +//! assert_eq!(tx_graph, restored_tx_graph); |
51 | 54 | //! ``` |
52 | 55 | //! |
53 | | -//! A [`TxGraph`] can also be updated with another [`TxGraph`]. |
| 56 | +//! A [`TxGraph`] can also be updated with another [`TxGraph`] which merges them together. |
54 | 57 | //! |
55 | 58 | //! ``` |
56 | | -//! # use bdk_chain::BlockId; |
| 59 | +//! # use bdk_chain::{Append, BlockId}; |
57 | 60 | //! # use bdk_chain::tx_graph::TxGraph; |
58 | 61 | //! # use bdk_chain::example_utils::*; |
59 | 62 | //! # use bitcoin::Transaction; |
@@ -1212,11 +1215,6 @@ impl<A> Default for ChangeSet<A> { |
1212 | 1215 | } |
1213 | 1216 |
|
1214 | 1217 | impl<A> ChangeSet<A> { |
1215 | | - /// Returns true if the [`ChangeSet`] is empty (no transactions or txouts). |
1216 | | - pub fn is_empty(&self) -> bool { |
1217 | | - self.txs.is_empty() && self.txouts.is_empty() |
1218 | | - } |
1219 | | - |
1220 | 1218 | /// Iterates over all outpoints contained within [`ChangeSet`]. |
1221 | 1219 | pub fn txouts(&self) -> impl Iterator<Item = (OutPoint, &TxOut)> { |
1222 | 1220 | self.txs |
|
0 commit comments