@@ -437,7 +437,7 @@ impl<A: Clone + Ord> TxGraph<A> {
437
437
///
438
438
/// The supplied closure returns an `Option<T>`, allowing the caller to map each `Transaction`
439
439
/// it visits and decide whether to visit ancestors.
440
- pub fn walk_ancestors < ' g , T , F , O > ( & ' g self , tx : T , walk_map : F ) -> TxAncestors < ' g , A , F >
440
+ pub fn walk_ancestors < ' g , T , F , O > ( & ' g self , tx : T , walk_map : F ) -> TxAncestors < ' g , A , F , O >
441
441
where
442
442
T : Into < Arc < Transaction > > ,
443
443
F : FnMut ( usize , Arc < Transaction > ) -> Option < O > + ' g ,
@@ -455,7 +455,7 @@ impl<A: Clone + Ord> TxGraph<A> {
455
455
///
456
456
/// The supplied closure returns an `Option<T>`, allowing the caller to map each node it visits
457
457
/// and decide whether to visit descendants.
458
- pub fn walk_descendants < ' g , F , O > ( & ' g self , txid : Txid , walk_map : F ) -> TxDescendants < A , F >
458
+ pub fn walk_descendants < ' g , F , O > ( & ' g self , txid : Txid , walk_map : F ) -> TxDescendants < A , F , O >
459
459
where
460
460
F : FnMut ( usize , Txid ) -> Option < O > + ' g ,
461
461
{
@@ -472,7 +472,7 @@ impl<A> TxGraph<A> {
472
472
& ' g self ,
473
473
tx : & ' g Transaction ,
474
474
walk_map : F ,
475
- ) -> TxDescendants < A , F >
475
+ ) -> TxDescendants < A , F , O >
476
476
where
477
477
F : FnMut ( usize , Txid ) -> Option < O > + ' g ,
478
478
{
@@ -1151,14 +1151,20 @@ impl<A> AsRef<TxGraph<A>> for TxGraph<A> {
1151
1151
/// Returned by the [`walk_ancestors`] method of [`TxGraph`].
1152
1152
///
1153
1153
/// [`walk_ancestors`]: TxGraph::walk_ancestors
1154
- pub struct TxAncestors < ' g , A , F > {
1154
+ pub struct TxAncestors < ' g , A , F , O >
1155
+ where
1156
+ F : FnMut ( usize , Arc < Transaction > ) -> Option < O > ,
1157
+ {
1155
1158
graph : & ' g TxGraph < A > ,
1156
1159
visited : HashSet < Txid > ,
1157
1160
queue : VecDeque < ( usize , Arc < Transaction > ) > ,
1158
1161
filter_map : F ,
1159
1162
}
1160
1163
1161
- impl < ' g , A , F > TxAncestors < ' g , A , F > {
1164
+ impl < ' g , A , F , O > TxAncestors < ' g , A , F , O >
1165
+ where
1166
+ F : FnMut ( usize , Arc < Transaction > ) -> Option < O > ,
1167
+ {
1162
1168
/// Creates a `TxAncestors` that includes the starting `Transaction` when iterating.
1163
1169
pub ( crate ) fn new_include_root (
1164
1170
graph : & ' g TxGraph < A > ,
@@ -1233,6 +1239,11 @@ impl<'g, A, F> TxAncestors<'g, A, F> {
1233
1239
ancestors
1234
1240
}
1235
1241
1242
+ /// Traverse all ancestors that are not filtered out by the provided closure.
1243
+ pub fn run_until_finished ( self ) {
1244
+ self . for_each ( |_| { } )
1245
+ }
1246
+
1236
1247
fn populate_queue ( & mut self , depth : usize , tx : Arc < Transaction > ) {
1237
1248
let ancestors = tx
1238
1249
. input
@@ -1245,7 +1256,7 @@ impl<'g, A, F> TxAncestors<'g, A, F> {
1245
1256
}
1246
1257
}
1247
1258
1248
- impl < ' g , A , F , O > Iterator for TxAncestors < ' g , A , F >
1259
+ impl < ' g , A , F , O > Iterator for TxAncestors < ' g , A , F , O >
1249
1260
where
1250
1261
F : FnMut ( usize , Arc < Transaction > ) -> Option < O > ,
1251
1262
{
@@ -1271,14 +1282,20 @@ where
1271
1282
/// Returned by the [`walk_descendants`] method of [`TxGraph`].
1272
1283
///
1273
1284
/// [`walk_descendants`]: TxGraph::walk_descendants
1274
- pub struct TxDescendants < ' g , A , F > {
1285
+ pub struct TxDescendants < ' g , A , F , O >
1286
+ where
1287
+ F : FnMut ( usize , Txid ) -> Option < O > ,
1288
+ {
1275
1289
graph : & ' g TxGraph < A > ,
1276
1290
visited : HashSet < Txid > ,
1277
1291
queue : VecDeque < ( usize , Txid ) > ,
1278
1292
filter_map : F ,
1279
1293
}
1280
1294
1281
- impl < ' g , A , F > TxDescendants < ' g , A , F > {
1295
+ impl < ' g , A , F , O > TxDescendants < ' g , A , F , O >
1296
+ where
1297
+ F : FnMut ( usize , Txid ) -> Option < O > ,
1298
+ {
1282
1299
/// Creates a `TxDescendants` that includes the starting `txid` when iterating.
1283
1300
#[ allow( unused) ]
1284
1301
pub ( crate ) fn new_include_root ( graph : & ' g TxGraph < A > , txid : Txid , filter_map : F ) -> Self {
@@ -1342,9 +1359,12 @@ impl<'g, A, F> TxDescendants<'g, A, F> {
1342
1359
}
1343
1360
descendants
1344
1361
}
1345
- }
1346
1362
1347
- impl < ' g , A , F > TxDescendants < ' g , A , F > {
1363
+ /// Traverse all descendants that are not filtered out by the provided closure.
1364
+ pub fn run_until_finished ( self ) {
1365
+ self . for_each ( |_| { } )
1366
+ }
1367
+
1348
1368
fn populate_queue ( & mut self , depth : usize , txid : Txid ) {
1349
1369
let spend_paths = self
1350
1370
. graph
@@ -1356,7 +1376,7 @@ impl<'g, A, F> TxDescendants<'g, A, F> {
1356
1376
}
1357
1377
}
1358
1378
1359
- impl < ' g , A , F , O > Iterator for TxDescendants < ' g , A , F >
1379
+ impl < ' g , A , F , O > Iterator for TxDescendants < ' g , A , F , O >
1360
1380
where
1361
1381
F : FnMut ( usize , Txid ) -> Option < O > ,
1362
1382
{
0 commit comments