Skip to content

Commit f68cfa8

Browse files
committed
feat(chain): Add method for constructing TxGraph from a ChangeSet
* Added a `from_changeset()` function to `TxGraph` implementation * This function initializes a new `TxGraph` and applies the given `ChangeSet` * The method allows constructing a `TxGraph` directly from a `ChangeSet`, simplifying graph creation.
1 parent 5817ed0 commit f68cfa8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

crates/chain/src/tx_graph.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,13 @@ impl<A: Anchor> TxGraph<A> {
12161216
self.try_list_expected_spk_txids(chain, chain_tip, indexer, spk_index_range)
12171217
.map(|r| r.expect("infallible"))
12181218
}
1219+
1220+
/// Construct a `TxGraph` from a `changeset`.
1221+
pub fn from_changeset(changeset: ChangeSet<A>) -> Self {
1222+
let mut graph = Self::default();
1223+
graph.apply_changeset(changeset);
1224+
graph
1225+
}
12191226
}
12201227

12211228
/// The [`ChangeSet`] represents changes to a [`TxGraph`].

0 commit comments

Comments
 (0)