1414#[ macro_use]
1515extern crate alloc;
1616
17+ #[ allow( unused_imports) ]
18+ #[ macro_use]
19+ extern crate bdk_common;
20+
1721use alloc:: sync:: Arc ;
1822use bdk_core:: collections:: { HashMap , HashSet } ;
1923use bdk_core:: { BlockId , CheckPoint } ;
2024use bitcoin:: { Block , BlockHash , Transaction , Txid } ;
2125use bitcoincore_rpc:: { bitcoincore_rpc_json, RpcApi } ;
2226use core:: ops:: Deref ;
2327
24- #[ cfg( feature = "tracing-logs" ) ]
25- use tracing:: trace;
26-
2728pub mod bip158;
2829
2930pub use bitcoincore_rpc;
@@ -127,8 +128,7 @@ where
127128 pub fn mempool_at ( & mut self , sync_time : u64 ) -> Result < MempoolEvent , bitcoincore_rpc:: Error > {
128129 let client = & * self . client ;
129130
130- #[ cfg( feature = "tracing-logs" ) ]
131- trace ! (
131+ log_trace ! (
132132 start_height = self . start_height,
133133 sync_time = sync_time,
134134 "enter mempool_at"
@@ -174,8 +174,7 @@ where
174174 ..Default :: default ( )
175175 } ;
176176
177- #[ cfg( feature = "tracing-logs" ) ]
178- trace ! (
177+ log_trace ! (
179178 rpc_mempool_count = rpc_mempool_txids. len( ) ,
180179 rpc_height = rpc_tip_height,
181180 rpc_block_hash = %rpc_tip_hash,
@@ -218,8 +217,7 @@ where
218217
219218 /// Emit the next block height and block (if any).
220219 pub fn next_block ( & mut self ) -> Result < Option < BlockEvent < Block > > , bitcoincore_rpc:: Error > {
221- #[ cfg( feature = "tracing-logs" ) ]
222- trace ! (
220+ log_trace ! (
223221 last_block_height = self . last_block. as_ref( ) . map( |r| r. height) ,
224222 "enter next_block"
225223 ) ;
@@ -229,8 +227,7 @@ where
229227 for tx in & block. txdata {
230228 self . mempool_snapshot . remove ( & tx. compute_txid ( ) ) ;
231229 }
232- #[ cfg( feature = "tracing-logs" ) ]
233- trace ! (
230+ log_trace ! (
234231 block_height = checkpoint. height( ) ,
235232 tx_count = block. txdata. len( ) ,
236233 "emit block"
@@ -309,8 +306,7 @@ where
309306 C : Deref ,
310307 C :: Target : RpcApi ,
311308{
312- #[ cfg( feature = "tracing-logs" ) ]
313- trace ! (
309+ log_trace ! (
314310 last_block_height = emitter. last_block. as_ref( ) . map( |r| r. height) ,
315311 start_height = emitter. start_height,
316312 "enter poll_once"
@@ -324,16 +320,14 @@ where
324320 let next_hash = client. get_block_hash ( emitter. start_height as _ ) ?;
325321 // make sure last emission is still in best chain
326322 if client. get_block_hash ( last_res. height as _ ) ? != last_res. hash {
327- #[ cfg( feature = "tracing-logs" ) ]
328- trace ! ( "block not in best chain" ) ;
323+ log_trace ! ( "block not in best chain" ) ;
329324 return Ok ( PollResponse :: BlockNotInBestChain ) ;
330325 }
331326 next_hash
332327 } else {
333328 match last_res. nextblockhash {
334329 None => {
335- #[ cfg( feature = "tracing-logs" ) ]
336- trace ! ( "no more blocks" ) ;
330+ log_trace ! ( "no more blocks" ) ;
337331 return Ok ( PollResponse :: NoMoreBlocks ) ;
338332 }
339333 Some ( next_hash) => next_hash,
@@ -342,13 +336,11 @@ where
342336
343337 let res = client. get_block_info ( & next_hash) ?;
344338 if res. confirmations < 0 {
345- #[ cfg( feature = "tracing-logs" ) ]
346- trace ! ( "block not in best chain" ) ;
339+ log_trace ! ( "block not in best chain" ) ;
347340 return Ok ( PollResponse :: BlockNotInBestChain ) ;
348341 }
349342
350- #[ cfg( feature = "tracing-logs" ) ]
351- trace ! (
343+ log_trace ! (
352344 height = res. height,
353345 hash = %res. hash,
354346 "agreement found"
@@ -372,8 +364,7 @@ where
372364 } ;
373365
374366 // agreement point found
375- #[ cfg( feature = "tracing-logs" ) ]
376- trace ! (
367+ log_trace ! (
377368 "poll(): PollResponse::AgreementFound, height={}, hash={}" ,
378369 res. height,
379370 res. hash
0 commit comments