@@ -7,7 +7,7 @@ use bitcoin::{Block, OutPoint, Transaction, TxOut, Txid};
77
88use crate :: {
99 tx_graph:: { self , TxGraph } ,
10- Anchor , AnchorFromBlockPosition , BlockId , Indexer , Merge ,
10+ Anchor , BlockId , Indexer , Merge , TxPosInBlock ,
1111} ;
1212
1313/// The [`IndexedTxGraph`] combines a [`TxGraph`] and an [`Indexer`] implementation.
@@ -252,17 +252,17 @@ where
252252 }
253253}
254254
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 >
257257where
258258 I :: ChangeSet : Default + Merge ,
259- A : AnchorFromBlockPosition ,
259+ for < ' b > A : Anchor + From < TxPosInBlock < ' b > > ,
260+ I : Indexer ,
260261{
261262 /// Batch insert all transactions of the given `block` of `height`, filtering out those that are
262263 /// irrelevant.
263264 ///
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`].
266266 ///
267267 /// Relevancy is determined by the internal [`Indexer::is_tx_relevant`] implementation of `I`.
268268 /// Irrelevant transactions in `txs` will be ignored.
@@ -280,7 +280,12 @@ where
280280 changeset. indexer . merge ( self . index . index_tx ( tx) ) ;
281281 if self . index . is_tx_relevant ( tx) {
282282 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 ( ) ;
284289 changeset. tx_graph . merge ( self . graph . insert_tx ( tx. clone ( ) ) ) ;
285290 changeset
286291 . tx_graph
@@ -292,8 +297,7 @@ where
292297
293298 /// Batch insert all transactions of the given `block` of `height`.
294299 ///
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`].
297301 ///
298302 /// To only insert relevant transactions, use [`apply_block_relevant`] instead.
299303 ///
@@ -305,7 +309,12 @@ where
305309 } ;
306310 let mut graph = tx_graph:: ChangeSet :: default ( ) ;
307311 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 ( ) ;
309318 graph. merge ( self . graph . insert_anchor ( tx. compute_txid ( ) , anchor) ) ;
310319 graph. merge ( self . graph . insert_tx ( tx. clone ( ) ) ) ;
311320 }
0 commit comments