@@ -20,7 +20,7 @@ use bitcoin::consensus::encode::{deserialize, serialize_hex};
2020#[ cfg( feature = "liquid" ) ]
2121use elements:: encode:: { deserialize, serialize_hex} ;
2222
23- use tracing :: instrument ;
23+ use instrumented_macro :: instrumented ;
2424
2525use crate :: chain:: { Block , BlockHash , BlockHeader , Network , Transaction , Txid } ;
2626use crate :: metrics:: { HistogramOpts , HistogramVec , Metrics } ;
@@ -44,7 +44,7 @@ lazy_static! {
4444const MAX_ATTEMPTS : u32 = 5 ;
4545const RETRY_WAIT_DURATION : Duration = Duration :: from_secs ( 1 ) ;
4646
47- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
47+ #[ instrumented ]
4848fn parse_hash < T > ( value : & Value ) -> Result < T >
4949where
5050 T : FromStr ,
5858 . chain_err ( || format ! ( "non-hex value: {}" , value) ) ?)
5959}
6060
61- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
61+ #[ instrumented ]
6262fn header_from_value ( value : Value ) -> Result < BlockHeader > {
6363 let header_hex = value
6464 . as_str ( )
@@ -153,7 +153,7 @@ struct Connection {
153153 signal : Waiter ,
154154}
155155
156- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
156+ #[ instrumented ]
157157fn tcp_connect ( addr : SocketAddr , signal : & Waiter ) -> Result < TcpStream > {
158158 loop {
159159 match TcpStream :: connect_timeout ( & addr, * DAEMON_CONNECTION_TIMEOUT ) {
@@ -176,7 +176,7 @@ fn tcp_connect(addr: SocketAddr, signal: &Waiter) -> Result<TcpStream> {
176176}
177177
178178impl Connection {
179- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
179+ #[ instrumented ]
180180 fn new (
181181 addr : SocketAddr ,
182182 cookie_getter : Arc < dyn CookieGetter > ,
@@ -196,12 +196,12 @@ impl Connection {
196196 } )
197197 }
198198
199- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
199+ #[ instrumented ]
200200 fn reconnect ( & self ) -> Result < Connection > {
201201 Connection :: new ( self . addr , self . cookie_getter . clone ( ) , self . signal . clone ( ) )
202202 }
203203
204- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
204+ #[ instrumented ]
205205 fn send ( & mut self , request : & str ) -> Result < ( ) > {
206206 let cookie = & self . cookie_getter . get ( ) ?;
207207 let msg = format ! (
@@ -215,7 +215,7 @@ impl Connection {
215215 } )
216216 }
217217
218- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
218+ #[ instrumented ]
219219 fn recv ( & mut self ) -> Result < String > {
220220 // TODO: use proper HTTP parser.
221221 let mut in_header = true ;
@@ -381,7 +381,7 @@ impl Daemon {
381381 Ok ( daemon)
382382 }
383383
384- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
384+ #[ instrumented ]
385385 pub fn reconnect ( & self ) -> Result < Daemon > {
386386 Ok ( Daemon {
387387 daemon_dir : self . daemon_dir . clone ( ) ,
@@ -396,7 +396,7 @@ impl Daemon {
396396 } )
397397 }
398398
399- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
399+ #[ instrumented ]
400400 pub fn list_blk_files ( & self ) -> Result < Vec < PathBuf > > {
401401 let path = self . blocks_dir . join ( "blk*.dat" ) ;
402402 debug ! ( "listing block files at {:?}" , path) ;
@@ -432,7 +432,7 @@ impl Daemon {
432432 self . network . magic ( )
433433 }
434434
435- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
435+ #[ instrumented ]
436436 fn call_jsonrpc ( & self , method : & str , request : & Value ) -> Result < Value > {
437437 let mut conn = self . conn . lock ( ) . unwrap ( ) ;
438438 let timer = self . latency . with_label_values ( & [ method] ) . start_timer ( ) ;
@@ -450,7 +450,7 @@ impl Daemon {
450450 Ok ( result)
451451 }
452452
453- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) , method = %method) ) ]
453+ #[ instrumented ( method = %method) ]
454454 fn handle_request ( & self , method : & str , params : & Value ) -> Result < Value > {
455455 let id = self . message_id . next ( ) ;
456456 let req = json ! ( { "method" : method, "params" : params, "id" : id} ) ;
@@ -473,12 +473,12 @@ impl Daemon {
473473 }
474474 }
475475
476- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
476+ #[ instrumented ]
477477 fn request ( & self , method : & str , params : Value ) -> Result < Value > {
478478 self . retry_request ( method, & params)
479479 }
480480
481- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
481+ #[ instrumented ]
482482 fn retry_reconnect ( & self ) -> Daemon {
483483 // XXX add a max reconnection attempts limit?
484484 loop {
@@ -493,14 +493,14 @@ impl Daemon {
493493
494494 // Send requests in parallel over multiple RPC connections as individual JSON-RPC requests (with no JSON-RPC batching),
495495 // buffering the replies into a vector. If any of the requests fail, processing is terminated and an Err is returned.
496- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
496+ #[ instrumented ]
497497 fn requests ( & self , method : & str , params_list : Vec < Value > ) -> Result < Vec < Value > > {
498498 self . requests_iter ( method, params_list) . collect ( )
499499 }
500500
501501 // Send requests in parallel over multiple RPC connections, iterating over the results without buffering them.
502502 // Errors are included in the iterator and do not terminate other pending requests.
503- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
503+ #[ instrumented ]
504504 fn requests_iter < ' a > (
505505 & ' a self ,
506506 method : & ' a str ,
@@ -523,29 +523,29 @@ impl Daemon {
523523
524524 // bitcoind JSONRPC API:
525525
526- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
526+ #[ instrumented ]
527527 pub fn getblockchaininfo ( & self ) -> Result < BlockchainInfo > {
528528 let info: Value = self . request ( "getblockchaininfo" , json ! ( [ ] ) ) ?;
529529 Ok ( from_value ( info) . chain_err ( || "invalid blockchain info" ) ?)
530530 }
531531
532- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
532+ #[ instrumented ]
533533 fn getnetworkinfo ( & self ) -> Result < NetworkInfo > {
534534 let info: Value = self . request ( "getnetworkinfo" , json ! ( [ ] ) ) ?;
535535 Ok ( from_value ( info) . chain_err ( || "invalid network info" ) ?)
536536 }
537537
538- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
538+ #[ instrumented ]
539539 pub fn getbestblockhash ( & self ) -> Result < BlockHash > {
540540 parse_hash ( & self . request ( "getbestblockhash" , json ! ( [ ] ) ) ?)
541541 }
542542
543- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
543+ #[ instrumented ]
544544 pub fn getblockheader ( & self , blockhash : & BlockHash ) -> Result < BlockHeader > {
545545 header_from_value ( self . request ( "getblockheader" , json ! ( [ blockhash, /*verbose=*/ false ] ) ) ?)
546546 }
547547
548- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
548+ #[ instrumented ]
549549 pub fn getblockheaders ( & self , heights : & [ usize ] ) -> Result < Vec < BlockHeader > > {
550550 let heights: Vec < Value > = heights. iter ( ) . map ( |height| json ! ( [ height] ) ) . collect ( ) ;
551551 let params_list: Vec < Value > = self
@@ -560,20 +560,20 @@ impl Daemon {
560560 Ok ( result)
561561 }
562562
563- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
563+ #[ instrumented ]
564564 pub fn getblock ( & self , blockhash : & BlockHash ) -> Result < Block > {
565565 let block =
566566 block_from_value ( self . request ( "getblock" , json ! ( [ blockhash, /*verbose=*/ false ] ) ) ?) ?;
567567 assert_eq ! ( block. block_hash( ) , * blockhash) ;
568568 Ok ( block)
569569 }
570570
571- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
571+ #[ instrumented ]
572572 pub fn getblock_raw ( & self , blockhash : & BlockHash , verbose : u32 ) -> Result < Value > {
573573 self . request ( "getblock" , json ! ( [ blockhash, verbose] ) )
574574 }
575575
576- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
576+ #[ instrumented ]
577577 pub fn getblocks ( & self , blockhashes : & [ BlockHash ] ) -> Result < Vec < Block > > {
578578 let params_list: Vec < Value > = blockhashes
579579 . iter ( )
@@ -610,7 +610,7 @@ impl Daemon {
610610
611611 /// Fetch the given transactions in parallel over multiple threads and RPC connections,
612612 /// ignoring any missing ones and returning whatever is available.
613- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
613+ #[ instrumented ]
614614 pub fn gettransactions_available ( & self , txids : & [ & Txid ] ) -> Result < Vec < ( Txid , Transaction ) > > {
615615 const RPC_INVALID_ADDRESS_OR_KEY : i64 = -5 ;
616616
@@ -635,7 +635,7 @@ impl Daemon {
635635 . collect ( )
636636 }
637637
638- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
638+ #[ instrumented ]
639639 pub fn gettransaction_raw (
640640 & self ,
641641 txid : & Txid ,
@@ -645,24 +645,24 @@ impl Daemon {
645645 self . request ( "getrawtransaction" , json ! ( [ txid, verbose, blockhash] ) )
646646 }
647647
648- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
648+ #[ instrumented ]
649649 pub fn getmempooltx ( & self , txhash : & Txid ) -> Result < Transaction > {
650650 let value = self . request ( "getrawtransaction" , json ! ( [ txhash, /*verbose=*/ false ] ) ) ?;
651651 tx_from_value ( value)
652652 }
653653
654- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
654+ #[ instrumented ]
655655 pub fn getmempooltxids ( & self ) -> Result < HashSet < Txid > > {
656656 let res = self . request ( "getrawmempool" , json ! ( [ /*verbose=*/ false ] ) ) ?;
657657 Ok ( serde_json:: from_value ( res) . chain_err ( || "invalid getrawmempool reply" ) ?)
658658 }
659659
660- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
660+ #[ instrumented ]
661661 pub fn broadcast ( & self , tx : & Transaction ) -> Result < Txid > {
662662 self . broadcast_raw ( & serialize_hex ( tx) )
663663 }
664664
665- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
665+ #[ instrumented ]
666666 pub fn broadcast_raw ( & self , txhex : & str ) -> Result < Txid > {
667667 let txid = self . request ( "sendrawtransaction" , json ! ( [ txhex] ) ) ?;
668668 Ok (
@@ -674,7 +674,7 @@ impl Daemon {
674674 // Get estimated feerates for the provided confirmation targets using a batch RPC request
675675 // Missing estimates are logged but do not cause a failure, whatever is available is returned
676676 #[ allow( clippy:: float_cmp) ]
677- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
677+ #[ instrumented ]
678678 pub fn estimatesmartfee_batch ( & self , conf_targets : & [ u16 ] ) -> Result < HashMap < u16 , f64 > > {
679679 let params_list: Vec < Value > = conf_targets
680680 . iter ( )
@@ -709,7 +709,7 @@ impl Daemon {
709709 . collect ( ) )
710710 }
711711
712- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
712+ #[ instrumented ]
713713 fn get_all_headers ( & self , tip : & BlockHash ) -> Result < Vec < BlockHeader > > {
714714 let info: Value = self . request ( "getblockheader" , json ! ( [ tip] ) ) ?;
715715 let tip_height = info
@@ -737,7 +737,7 @@ impl Daemon {
737737 }
738738
739739 // Returns a list of BlockHeaders in ascending height (i.e. the tip is last).
740- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
740+ #[ instrumented ]
741741 pub fn get_new_headers (
742742 & self ,
743743 indexed_headers : & HeaderList ,
@@ -770,7 +770,7 @@ impl Daemon {
770770 Ok ( new_headers)
771771 }
772772
773- #[ instrument ( skip_all , fields ( module = module_path! ( ) , file = file! ( ) , line = line! ( ) ) ) ]
773+ #[ instrumented ]
774774 pub fn get_relayfee ( & self ) -> Result < f64 > {
775775 let relayfee = self . getnetworkinfo ( ) ?. relayfee ;
776776
0 commit comments