@@ -7,7 +7,7 @@ use bitcoin::{Block, OutPoint, Transaction, TxOut, Txid};
7
7
8
8
use crate :: {
9
9
tx_graph:: { self , TxGraph } ,
10
- Anchor , AnchorFromBlockPosition , BlockId , Indexer , Merge ,
10
+ Anchor , BlockId , Indexer , Merge , TxPosInBlock ,
11
11
} ;
12
12
13
13
/// The [`IndexedTxGraph`] combines a [`TxGraph`] and an [`Indexer`] implementation.
@@ -252,17 +252,17 @@ where
252
252
}
253
253
}
254
254
255
- /// Methods are available if the anchor (`A`) implements [`AnchorFromBlockPosition `].
256
- impl < A : Anchor , I : Indexer > IndexedTxGraph < A , I >
255
+ /// Methods are available if the anchor (`A`) can be created from [`TxPosInBlock `].
256
+ impl < A , I > IndexedTxGraph < A , I >
257
257
where
258
258
I :: ChangeSet : Default + Merge ,
259
- A : AnchorFromBlockPosition ,
259
+ for < ' b > A : Anchor + From < TxPosInBlock < ' b > > ,
260
+ I : Indexer ,
260
261
{
261
262
/// Batch insert all transactions of the given `block` of `height`, filtering out those that are
262
263
/// irrelevant.
263
264
///
264
- /// Each inserted transaction's anchor will be constructed from
265
- /// [`AnchorFromBlockPosition::from_block_position`].
265
+ /// Each inserted transaction's anchor will be constructed using [`TxPosInBlock`].
266
266
///
267
267
/// Relevancy is determined by the internal [`Indexer::is_tx_relevant`] implementation of `I`.
268
268
/// Irrelevant transactions in `txs` will be ignored.
@@ -280,7 +280,12 @@ where
280
280
changeset. indexer . merge ( self . index . index_tx ( tx) ) ;
281
281
if self . index . is_tx_relevant ( tx) {
282
282
let txid = tx. compute_txid ( ) ;
283
- let anchor = A :: from_block_position ( block, block_id, tx_pos) ;
283
+ let anchor = TxPosInBlock {
284
+ block,
285
+ block_id,
286
+ tx_pos,
287
+ }
288
+ . into ( ) ;
284
289
changeset. tx_graph . merge ( self . graph . insert_tx ( tx. clone ( ) ) ) ;
285
290
changeset
286
291
. tx_graph
@@ -292,8 +297,7 @@ where
292
297
293
298
/// Batch insert all transactions of the given `block` of `height`.
294
299
///
295
- /// Each inserted transaction's anchor will be constructed from
296
- /// [`AnchorFromBlockPosition::from_block_position`].
300
+ /// Each inserted transaction's anchor will be constructed using [`TxPosInBlock`].
297
301
///
298
302
/// To only insert relevant transactions, use [`apply_block_relevant`] instead.
299
303
///
@@ -305,7 +309,12 @@ where
305
309
} ;
306
310
let mut graph = tx_graph:: ChangeSet :: default ( ) ;
307
311
for ( tx_pos, tx) in block. txdata . iter ( ) . enumerate ( ) {
308
- let anchor = A :: from_block_position ( & block, block_id, tx_pos) ;
312
+ let anchor = TxPosInBlock {
313
+ block : & block,
314
+ block_id,
315
+ tx_pos,
316
+ }
317
+ . into ( ) ;
309
318
graph. merge ( self . graph . insert_anchor ( tx. compute_txid ( ) , anchor) ) ;
310
319
graph. merge ( self . graph . insert_tx ( tx. clone ( ) ) ) ;
311
320
}
0 commit comments