@@ -5,7 +5,7 @@ use bdk_chain::{
55 bitcoin:: { Address , Amount , Txid } ,
66 local_chain:: { CheckPoint , LocalChain } ,
77 spk_txout:: SpkTxOutIndex ,
8- Balance , BlockId , IndexedTxGraph , Merge ,
8+ Balance , BlockId , Merge , TxGraph ,
99} ;
1010use bdk_testenv:: { anyhow, TestEnv } ;
1111use bitcoin:: { hashes:: Hash , Block , OutPoint , ScriptBuf , WScriptHash } ;
@@ -148,7 +148,7 @@ fn test_into_tx_graph() -> anyhow::Result<()> {
148148 env. mine_blocks ( 101 , None ) ?;
149149
150150 let ( mut chain, _) = LocalChain :: from_genesis_hash ( env. rpc_client ( ) . get_block_hash ( 0 ) ?) ;
151- let mut indexed_tx_graph = IndexedTxGraph :: < BlockId , _ > :: new ( {
151+ let mut tx_graph = TxGraph :: < BlockId , _ > :: new ( {
152152 let mut index = SpkTxOutIndex :: < usize > :: default ( ) ;
153153 index. insert_spk ( 0 , addr_0. script_pubkey ( ) ) ;
154154 index. insert_spk ( 1 , addr_1. script_pubkey ( ) ) ;
@@ -161,8 +161,8 @@ fn test_into_tx_graph() -> anyhow::Result<()> {
161161 while let Some ( emission) = emitter. next_block ( ) ? {
162162 let height = emission. block_height ( ) ;
163163 let _ = chain. apply_update ( emission. checkpoint ) ?;
164- let indexed_additions = indexed_tx_graph . apply_block_relevant ( & emission. block , height) ;
165- assert ! ( indexed_additions . is_empty( ) ) ;
164+ let tx_graph_changeset = tx_graph . apply_block_relevant ( & emission. block , height) ;
165+ assert ! ( tx_graph_changeset . is_empty( ) ) ;
166166 }
167167
168168 // send 3 txs to a tracked address, these txs will be in the mempool
@@ -189,18 +189,17 @@ fn test_into_tx_graph() -> anyhow::Result<()> {
189189 assert ! ( emitter. next_block( ) ?. is_none( ) ) ;
190190
191191 let mempool_txs = emitter. mempool ( ) ?;
192- let indexed_additions = indexed_tx_graph . batch_insert_unconfirmed ( mempool_txs) ;
192+ let tx_graph_changeset = tx_graph . batch_insert_unconfirmed ( mempool_txs) ;
193193 assert_eq ! (
194- indexed_additions
195- . tx_graph
194+ tx_graph_changeset
196195 . txs
197196 . iter( )
198197 . map( |tx| tx. compute_txid( ) )
199198 . collect:: <BTreeSet <Txid >>( ) ,
200199 exp_txids,
201200 "changeset should have the 3 mempool transactions" ,
202201 ) ;
203- assert ! ( indexed_additions . tx_graph . anchors. is_empty( ) ) ;
202+ assert ! ( tx_graph_changeset . anchors. is_empty( ) ) ;
204203 }
205204
206205 // mine a block that confirms the 3 txs
@@ -222,10 +221,10 @@ fn test_into_tx_graph() -> anyhow::Result<()> {
222221 let emission = emitter. next_block ( ) ?. expect ( "must get mined block" ) ;
223222 let height = emission. block_height ( ) ;
224223 let _ = chain. apply_update ( emission. checkpoint ) ?;
225- let indexed_additions = indexed_tx_graph . apply_block_relevant ( & emission. block , height) ;
226- assert ! ( indexed_additions . tx_graph . txs. is_empty( ) ) ;
227- assert ! ( indexed_additions . tx_graph . txouts. is_empty( ) ) ;
228- assert_eq ! ( indexed_additions . tx_graph . anchors, exp_anchors) ;
224+ let tx_graph_changeset = tx_graph . apply_block_relevant ( & emission. block , height) ;
225+ assert ! ( tx_graph_changeset . txs. is_empty( ) ) ;
226+ assert ! ( tx_graph_changeset . txouts. is_empty( ) ) ;
227+ assert_eq ! ( tx_graph_changeset . anchors, exp_anchors) ;
229228 }
230229
231230 Ok ( ( ) )
@@ -276,7 +275,7 @@ fn ensure_block_emitted_after_reorg_is_at_reorg_height() -> anyhow::Result<()> {
276275
277276fn process_block (
278277 recv_chain : & mut LocalChain ,
279- recv_graph : & mut IndexedTxGraph < BlockId , SpkTxOutIndex < ( ) > > ,
278+ recv_graph : & mut TxGraph < BlockId , SpkTxOutIndex < ( ) > > ,
280279 block : Block ,
281280 block_height : u32 ,
282281) -> anyhow:: Result < ( ) > {
@@ -287,7 +286,7 @@ fn process_block(
287286
288287fn sync_from_emitter < C > (
289288 recv_chain : & mut LocalChain ,
290- recv_graph : & mut IndexedTxGraph < BlockId , SpkTxOutIndex < ( ) > > ,
289+ recv_graph : & mut TxGraph < BlockId , SpkTxOutIndex < ( ) > > ,
291290 emitter : & mut Emitter < C > ,
292291) -> anyhow:: Result < ( ) >
293292where
@@ -302,13 +301,11 @@ where
302301
303302fn get_balance (
304303 recv_chain : & LocalChain ,
305- recv_graph : & IndexedTxGraph < BlockId , SpkTxOutIndex < ( ) > > ,
304+ recv_graph : & TxGraph < BlockId , SpkTxOutIndex < ( ) > > ,
306305) -> anyhow:: Result < Balance > {
307306 let chain_tip = recv_chain. tip ( ) . block_id ( ) ;
308307 let outpoints = recv_graph. index . outpoints ( ) . clone ( ) ;
309- let balance = recv_graph
310- . graph ( )
311- . balance ( recv_chain, chain_tip, outpoints, |_, _| true ) ;
308+ let balance = recv_graph. balance ( recv_chain, chain_tip, outpoints, |_, _| true ) ;
312309 Ok ( balance)
313310}
314311
@@ -340,7 +337,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> {
340337
341338 // setup receiver
342339 let ( mut recv_chain, _) = LocalChain :: from_genesis_hash ( env. rpc_client ( ) . get_block_hash ( 0 ) ?) ;
343- let mut recv_graph = IndexedTxGraph :: < BlockId , _ > :: new ( {
340+ let mut recv_graph = TxGraph :: < BlockId , _ > :: new ( {
344341 let mut recv_index = SpkTxOutIndex :: default ( ) ;
345342 recv_index. insert_spk ( ( ) , spk_to_track. clone ( ) ) ;
346343 recv_index
0 commit comments