From 97890450db27bd226cac486abf1f3d472e307f0c Mon Sep 17 00:00:00 2001 From: Dmenec Date: Mon, 25 May 2026 12:47:39 +0200 Subject: [PATCH] feat(chain): add walk_ancestors_from_root to TxGraph --- crates/chain/src/tx_graph.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/chain/src/tx_graph.rs b/crates/chain/src/tx_graph.rs index 72f8f4876..e7ae19010 100644 --- a/crates/chain/src/tx_graph.rs +++ b/crates/chain/src/tx_graph.rs @@ -498,6 +498,24 @@ impl TxGraph { TxAncestors::new_exclude_root(self, tx, walk_map) } + /// Creates an iterator that filters and maps ancestor transactions. + /// + /// Similar to [`Self::walk_ancestors`] but includes the starting `tx` in the iteration at + /// `depth` 0. + /// + /// Refer to [`Self::walk_ancestors`] for `walk_map` usage. + pub fn walk_ancestors_from_root<'g, T, F, O>( + &'g self, + tx: T, + walk_map: F, + ) -> TxAncestors<'g, A, F, O> + where + T: Into>, + F: FnMut(usize, Arc) -> Option + 'g, + { + TxAncestors::new_include_root(self, tx, walk_map) + } + /// Creates an iterator that filters and maps descendants from the starting `txid`. /// /// The supplied closure takes in two inputs `(depth, descendant_txid)`: