14
14
#[ macro_use]
15
15
extern crate alloc;
16
16
17
+ #[ allow( unused_imports) ]
18
+ #[ macro_use]
19
+ extern crate bdk_common;
20
+
17
21
use alloc:: sync:: Arc ;
18
22
use bdk_core:: collections:: { HashMap , HashSet } ;
19
23
use bdk_core:: { BlockId , CheckPoint } ;
20
24
use bitcoin:: { Block , BlockHash , Transaction , Txid } ;
21
25
use bitcoincore_rpc:: { bitcoincore_rpc_json, RpcApi } ;
22
26
use core:: ops:: Deref ;
23
27
24
- #[ cfg( feature = "tracing-logs" ) ]
25
- use tracing:: trace;
26
-
27
28
pub mod bip158;
28
29
29
30
pub use bitcoincore_rpc;
@@ -127,8 +128,7 @@ where
127
128
pub fn mempool_at ( & mut self , sync_time : u64 ) -> Result < MempoolEvent , bitcoincore_rpc:: Error > {
128
129
let client = & * self . client ;
129
130
130
- #[ cfg( feature = "tracing-logs" ) ]
131
- trace ! (
131
+ log_trace ! (
132
132
start_height = self . start_height,
133
133
sync_time = sync_time,
134
134
"enter mempool_at"
@@ -174,8 +174,7 @@ where
174
174
..Default :: default ( )
175
175
} ;
176
176
177
- #[ cfg( feature = "tracing-logs" ) ]
178
- trace ! (
177
+ log_trace ! (
179
178
rpc_mempool_count = rpc_mempool_txids. len( ) ,
180
179
rpc_height = rpc_tip_height,
181
180
rpc_block_hash = %rpc_tip_hash,
@@ -218,8 +217,7 @@ where
218
217
219
218
/// Emit the next block height and block (if any).
220
219
pub fn next_block ( & mut self ) -> Result < Option < BlockEvent < Block > > , bitcoincore_rpc:: Error > {
221
- #[ cfg( feature = "tracing-logs" ) ]
222
- trace ! (
220
+ log_trace ! (
223
221
last_block_height = self . last_block. as_ref( ) . map( |r| r. height) ,
224
222
"enter next_block"
225
223
) ;
@@ -229,8 +227,7 @@ where
229
227
for tx in & block. txdata {
230
228
self . mempool_snapshot . remove ( & tx. compute_txid ( ) ) ;
231
229
}
232
- #[ cfg( feature = "tracing-logs" ) ]
233
- trace ! (
230
+ log_trace ! (
234
231
block_height = checkpoint. height( ) ,
235
232
tx_count = block. txdata. len( ) ,
236
233
"emit block"
@@ -309,8 +306,7 @@ where
309
306
C : Deref ,
310
307
C :: Target : RpcApi ,
311
308
{
312
- #[ cfg( feature = "tracing-logs" ) ]
313
- trace ! (
309
+ log_trace ! (
314
310
last_block_height = emitter. last_block. as_ref( ) . map( |r| r. height) ,
315
311
start_height = emitter. start_height,
316
312
"enter poll_once"
@@ -324,16 +320,14 @@ where
324
320
let next_hash = client. get_block_hash ( emitter. start_height as _ ) ?;
325
321
// make sure last emission is still in best chain
326
322
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" ) ;
329
324
return Ok ( PollResponse :: BlockNotInBestChain ) ;
330
325
}
331
326
next_hash
332
327
} else {
333
328
match last_res. nextblockhash {
334
329
None => {
335
- #[ cfg( feature = "tracing-logs" ) ]
336
- trace ! ( "no more blocks" ) ;
330
+ log_trace ! ( "no more blocks" ) ;
337
331
return Ok ( PollResponse :: NoMoreBlocks ) ;
338
332
}
339
333
Some ( next_hash) => next_hash,
@@ -342,13 +336,11 @@ where
342
336
343
337
let res = client. get_block_info ( & next_hash) ?;
344
338
if res. confirmations < 0 {
345
- #[ cfg( feature = "tracing-logs" ) ]
346
- trace ! ( "block not in best chain" ) ;
339
+ log_trace ! ( "block not in best chain" ) ;
347
340
return Ok ( PollResponse :: BlockNotInBestChain ) ;
348
341
}
349
342
350
- #[ cfg( feature = "tracing-logs" ) ]
351
- trace ! (
343
+ log_trace ! (
352
344
height = res. height,
353
345
hash = %res. hash,
354
346
"agreement found"
@@ -372,8 +364,7 @@ where
372
364
} ;
373
365
374
366
// agreement point found
375
- #[ cfg( feature = "tracing-logs" ) ]
376
- trace ! (
367
+ log_trace ! (
377
368
"poll(): PollResponse::AgreementFound, height={}, hash={}" ,
378
369
res. height,
379
370
res. hash
0 commit comments