@@ -644,11 +644,9 @@ impl PeerNetwork {
644
644
let ( p2p_handle, bound_p2p_addr) = net. bind ( my_addr) ?;
645
645
let ( http_handle, bound_http_addr) = net. bind ( http_addr) ?;
646
646
647
- test_debug ! (
647
+ debug ! (
648
648
"{:?}: bound on p2p {:?}, http {:?}" ,
649
- & self . local_peer,
650
- bound_p2p_addr,
651
- bound_http_addr
649
+ & self . local_peer, bound_p2p_addr, bound_http_addr
652
650
) ;
653
651
654
652
self . network = Some ( net) ;
@@ -898,6 +896,12 @@ impl PeerNetwork {
898
896
return Err ( e) ;
899
897
}
900
898
Ok ( sz) => {
899
+ if sz > 0 {
900
+ debug ! (
901
+ "Sent {} bytes on p2p socket {:?} for conversation {:?}" ,
902
+ sz, client_sock, convo
903
+ ) ;
904
+ }
901
905
total_sent += sz;
902
906
if sz == 0 {
903
907
break ;
@@ -1185,7 +1189,7 @@ impl PeerNetwork {
1185
1189
1186
1190
let next_event_id = match self . network {
1187
1191
None => {
1188
- test_debug ! ( "{:?}: network not connected" , & self . local_peer) ;
1192
+ debug ! ( "{:?}: network not connected" , & self . local_peer) ;
1189
1193
return Err ( net_error:: NotConnected ) ;
1190
1194
}
1191
1195
Some ( ref mut network) => {
@@ -1481,7 +1485,7 @@ impl PeerNetwork {
1481
1485
( convo. to_neighbor_key ( ) , Some ( neighbor) )
1482
1486
}
1483
1487
None => {
1484
- test_debug ! (
1488
+ debug ! (
1485
1489
"No such neighbor in peer DB, but will ban nevertheless: {:?}" ,
1486
1490
convo. to_neighbor_key( )
1487
1491
) ;
@@ -1645,11 +1649,9 @@ impl PeerNetwork {
1645
1649
1646
1650
// already connected?
1647
1651
if let Some ( event_id) = self . get_event_id ( & neighbor_key) {
1648
- test_debug ! (
1652
+ debug ! (
1649
1653
"{:?}: already connected to {:?} on event {}" ,
1650
- & self . local_peer,
1651
- & neighbor_key,
1652
- event_id
1654
+ & self . local_peer, & neighbor_key, event_id
1653
1655
) ;
1654
1656
return Err ( net_error:: AlreadyConnected ( event_id, neighbor_key. clone ( ) ) ) ;
1655
1657
}
@@ -1927,7 +1929,7 @@ impl PeerNetwork {
1927
1929
match self . events . get ( & peer_key) {
1928
1930
None => {
1929
1931
// not connected
1930
- test_debug ! ( "Could not sign for peer {:?}: not connected" , peer_key) ;
1932
+ debug ! ( "Could not sign for peer {:?}: not connected" , peer_key) ;
1931
1933
Err ( net_error:: PeerNotConnected )
1932
1934
}
1933
1935
Some ( event_id) => self . sign_for_p2p ( * event_id, message_payload) ,
@@ -1947,7 +1949,7 @@ impl PeerNetwork {
1947
1949
message_payload,
1948
1950
) ;
1949
1951
}
1950
- test_debug ! ( "Could not sign for peer {}: not connected" , event_id) ;
1952
+ debug ! ( "Could not sign for peer {}: not connected" , event_id) ;
1951
1953
Err ( net_error:: PeerNotConnected )
1952
1954
}
1953
1955
@@ -1968,7 +1970,7 @@ impl PeerNetwork {
1968
1970
message_payload,
1969
1971
) ;
1970
1972
}
1971
- test_debug ! ( "Could not sign for peer {}: not connected" , event_id) ;
1973
+ debug ! ( "Could not sign for peer {}: not connected" , event_id) ;
1972
1974
Err ( net_error:: PeerNotConnected )
1973
1975
}
1974
1976
@@ -2042,7 +2044,7 @@ impl PeerNetwork {
2042
2044
match ( self . peers . remove ( & event_id) , self . sockets . remove ( & event_id) ) {
2043
2045
( Some ( convo) , Some ( sock) ) => ( convo, sock) ,
2044
2046
( Some ( convo) , None ) => {
2045
- test_debug ! ( "{:?}: Rogue socket event {}" , & self . local_peer, event_id) ;
2047
+ debug ! ( "{:?}: Rogue socket event {}" , & self . local_peer, event_id) ;
2046
2048
self . peers . insert ( event_id, convo) ;
2047
2049
return Err ( net_error:: PeerNotConnected ) ;
2048
2050
}
@@ -2055,7 +2057,7 @@ impl PeerNetwork {
2055
2057
return Err ( net_error:: PeerNotConnected ) ;
2056
2058
}
2057
2059
( None , None ) => {
2058
- test_debug ! ( "{:?}: Rogue socket event {}" , & self . local_peer, event_id) ;
2060
+ debug ! ( "{:?}: Rogue socket event {}" , & self . local_peer, event_id) ;
2059
2061
return Err ( net_error:: PeerNotConnected ) ;
2060
2062
}
2061
2063
} ;
@@ -2184,7 +2186,7 @@ impl PeerNetwork {
2184
2186
) {
2185
2187
Ok ( ( convo_unhandled, alive) ) => ( convo_unhandled, alive) ,
2186
2188
Err ( _e) => {
2187
- test_debug ! (
2189
+ debug ! (
2188
2190
"{:?}: Connection to {:?} failed: {:?}" ,
2189
2191
& self . local_peer,
2190
2192
self . get_p2p_convo( * event_id) ,
@@ -2196,7 +2198,7 @@ impl PeerNetwork {
2196
2198
} ;
2197
2199
2198
2200
if !alive {
2199
- test_debug ! (
2201
+ debug ! (
2200
2202
"{:?}: Connection to {:?} is no longer alive" ,
2201
2203
& self . local_peer,
2202
2204
self . get_p2p_convo( * event_id) ,
@@ -2383,11 +2385,9 @@ impl PeerNetwork {
2383
2385
}
2384
2386
} ;
2385
2387
if neighbor. allowed < 0 || ( neighbor. allowed as u64 ) > now {
2386
- test_debug ! (
2388
+ debug ! (
2387
2389
"{:?}: event {} is allowed: {:?}" ,
2388
- & self . local_peer,
2389
- event_id,
2390
- & nk
2390
+ & self . local_peer, event_id, & nk
2391
2391
) ;
2392
2392
safe. insert ( * event_id) ;
2393
2393
}
@@ -2474,17 +2474,19 @@ impl PeerNetwork {
2474
2474
let mut relay_handles = std:: mem:: replace ( & mut self . relay_handles , HashMap :: new ( ) ) ;
2475
2475
for ( event_id, handle_list) in relay_handles. iter_mut ( ) {
2476
2476
if handle_list. len ( ) == 0 {
2477
+ debug ! ( "No handles for event {}" , event_id) ;
2477
2478
drained. push ( * event_id) ;
2478
2479
continue ;
2479
2480
}
2480
2481
2481
- test_debug ! (
2482
+ debug ! (
2482
2483
"Flush {} relay handles to event {}" ,
2483
2484
handle_list. len( ) ,
2484
2485
event_id
2485
2486
) ;
2486
2487
2487
2488
while handle_list. len ( ) > 0 {
2489
+ debug ! ( "Flush {} relay handles" , handle_list. len( ) ) ;
2488
2490
let res = self . with_p2p_convo ( * event_id, |_network, convo, client_sock| {
2489
2491
if let Some ( handle) = handle_list. front_mut ( ) {
2490
2492
let ( num_sent, flushed) =
@@ -2496,12 +2498,9 @@ impl PeerNetwork {
2496
2498
}
2497
2499
} ;
2498
2500
2499
- test_debug ! (
2501
+ debug ! (
2500
2502
"Flushed relay handle to {:?} ({:?}): sent={}, flushed={}" ,
2501
- client_sock,
2502
- convo,
2503
- num_sent,
2504
- flushed
2503
+ client_sock, convo, num_sent, flushed
2505
2504
) ;
2506
2505
return Ok ( ( num_sent, flushed) ) ;
2507
2506
}
@@ -2512,14 +2511,15 @@ impl PeerNetwork {
2512
2511
Ok ( Ok ( x) ) => x,
2513
2512
Ok ( Err ( _) ) | Err ( _) => {
2514
2513
// connection broken; next list
2514
+ debug ! ( "Relay handle broken to event {}" , event_id) ;
2515
2515
broken. push ( * event_id) ;
2516
2516
break ;
2517
2517
}
2518
2518
} ;
2519
2519
2520
2520
if !flushed && num_sent == 0 {
2521
2521
// blocked on this peer's socket
2522
- test_debug ! ( "Relay handle to event {} is blocked" , event_id) ;
2522
+ debug ! ( "Relay handle to event {} is blocked" , event_id) ;
2523
2523
break ;
2524
2524
}
2525
2525
@@ -2553,7 +2553,7 @@ impl PeerNetwork {
2553
2553
/// Return true if we finish, and true if we're throttled
2554
2554
fn do_network_neighbor_walk ( & mut self , ibd : bool ) -> bool {
2555
2555
if cfg ! ( test) && self . connection_opts . disable_neighbor_walk {
2556
- test_debug ! ( "neighbor walk is disabled" ) ;
2556
+ debug ! ( "neighbor walk is disabled" ) ;
2557
2557
return true ;
2558
2558
}
2559
2559
@@ -2800,15 +2800,15 @@ impl PeerNetwork {
2800
2800
fn need_public_ip ( & mut self ) -> bool {
2801
2801
if !self . public_ip_learned {
2802
2802
// IP was given, not learned. nothing to do
2803
- test_debug ! ( "{:?}: IP address was given to us" , & self . local_peer) ;
2803
+ debug ! ( "{:?}: IP address was given to us" , & self . local_peer) ;
2804
2804
return false ;
2805
2805
}
2806
2806
if self . local_peer . public_ip_address . is_some ( )
2807
2807
&& self . public_ip_learned_at + self . connection_opts . public_ip_timeout
2808
2808
>= get_epoch_time_secs ( )
2809
2809
{
2810
2810
// still fresh
2811
- test_debug ! ( "{:?}: learned IP address is still fresh" , & self . local_peer) ;
2811
+ debug ! ( "{:?}: learned IP address is still fresh" , & self . local_peer) ;
2812
2812
return false ;
2813
2813
}
2814
2814
let throttle_timeout = if self . local_peer . public_ip_address . is_none ( ) {
@@ -2871,7 +2871,7 @@ impl PeerNetwork {
2871
2871
match self . do_learn_public_ip ( ) {
2872
2872
Ok ( b) => {
2873
2873
if !b {
2874
- test_debug ! ( "{:?}: try do_learn_public_ip again" , & self . local_peer) ;
2874
+ debug ! ( "{:?}: try do_learn_public_ip again" , & self . local_peer) ;
2875
2875
return false ;
2876
2876
}
2877
2877
}
@@ -2958,15 +2958,15 @@ impl PeerNetwork {
2958
2958
2959
2959
for ( _, block, _) in network_result. blocks . iter ( ) {
2960
2960
if block_set. contains ( & block. block_hash ( ) ) {
2961
- test_debug ! ( "Duplicate block {}" , block. block_hash( ) ) ;
2961
+ debug ! ( "Duplicate block {}" , block. block_hash( ) ) ;
2962
2962
}
2963
2963
block_set. insert ( block. block_hash ( ) ) ;
2964
2964
}
2965
2965
2966
2966
for ( _, mblocks, _) in network_result. confirmed_microblocks . iter ( ) {
2967
2967
for mblock in mblocks. iter ( ) {
2968
2968
if microblock_set. contains ( & mblock. block_hash ( ) ) {
2969
- test_debug ! ( "Duplicate microblock {}" , mblock. block_hash( ) ) ;
2969
+ debug ! ( "Duplicate microblock {}" , mblock. block_hash( ) ) ;
2970
2970
}
2971
2971
microblock_set. insert ( mblock. block_hash ( ) ) ;
2972
2972
}
@@ -4209,7 +4209,7 @@ impl PeerNetwork {
4209
4209
}
4210
4210
None => {
4211
4211
// skip this step -- no DNS client available
4212
- test_debug ! (
4212
+ debug ! (
4213
4213
"{:?}: no DNS client provided; skipping block download" ,
4214
4214
& self . local_peer
4215
4215
) ;
@@ -4315,7 +4315,7 @@ impl PeerNetwork {
4315
4315
}
4316
4316
None => {
4317
4317
// skip this step -- no DNS client available
4318
- test_debug ! (
4318
+ debug ! (
4319
4319
"{:?}: no DNS client provided; skipping block download" ,
4320
4320
& self . local_peer
4321
4321
) ;
@@ -4364,7 +4364,11 @@ impl PeerNetwork {
4364
4364
convo. to_neighbor_key ( ) ,
4365
4365
) ,
4366
4366
None => {
4367
- test_debug ! ( "No such neighbor event={}" , event_id) ;
4367
+ debug ! (
4368
+ "{:?}: No such neighbor event={}" ,
4369
+ self . get_local_peer( ) ,
4370
+ event_id
4371
+ ) ;
4368
4372
return None ;
4369
4373
}
4370
4374
} ;
@@ -4373,10 +4377,9 @@ impl PeerNetwork {
4373
4377
let reciprocal_event_id = match self . find_reciprocal_event ( event_id) {
4374
4378
Some ( re) => re,
4375
4379
None => {
4376
- test_debug ! (
4380
+ debug ! (
4377
4381
"{:?}: no reciprocal conversation for {:?}" ,
4378
- & self . local_peer,
4379
- & neighbor_key
4382
+ & self . local_peer, & neighbor_key
4380
4383
) ;
4381
4384
return None ;
4382
4385
}
@@ -4390,32 +4393,26 @@ impl PeerNetwork {
4390
4393
convo. to_neighbor_key ( ) ,
4391
4394
) ,
4392
4395
None => {
4393
- test_debug ! (
4396
+ debug ! (
4394
4397
"{:?}: No reciprocal conversation for {} (event={})" ,
4395
- & self . local_peer,
4396
- & neighbor_key,
4397
- event_id
4398
+ & self . local_peer, & neighbor_key, event_id
4398
4399
) ;
4399
4400
return None ;
4400
4401
}
4401
4402
} ;
4402
4403
4403
4404
if !is_authenticated && !reciprocal_is_authenticated {
4404
- test_debug ! (
4405
+ debug ! (
4405
4406
"{:?}: {:?} and {:?} are not authenticated" ,
4406
- & self . local_peer,
4407
- & neighbor_key,
4408
- & reciprocal_neighbor_key
4407
+ & self . local_peer, & neighbor_key, & reciprocal_neighbor_key
4409
4408
) ;
4410
4409
return None ;
4411
4410
}
4412
4411
4413
4412
if !is_outbound && !reciprocal_is_outbound {
4414
- test_debug ! (
4413
+ debug ! (
4415
4414
"{:?}: {:?} and {:?} are not outbound" ,
4416
- & self . local_peer,
4417
- & neighbor_key,
4418
- & reciprocal_neighbor_key
4415
+ & self . local_peer, & neighbor_key, & reciprocal_neighbor_key
4419
4416
) ;
4420
4417
return None ;
4421
4418
}
@@ -5196,7 +5193,7 @@ impl PeerNetwork {
5196
5193
/// for. Add them to our network pingbacks
5197
5194
fn schedule_network_pingbacks ( & mut self , event_ids : Vec < usize > ) {
5198
5195
if cfg ! ( test) && self . connection_opts . disable_pingbacks {
5199
- test_debug ! ( "{:?}: pingbacks are disabled for testing" , & self . local_peer) ;
5196
+ debug ! ( "{:?}: pingbacks are disabled for testing" , & self . local_peer) ;
5200
5197
return ;
5201
5198
}
5202
5199
@@ -5278,7 +5275,7 @@ impl PeerNetwork {
5278
5275
}
5279
5276
}
5280
5277
5281
- test_debug ! (
5278
+ debug ! (
5282
5279
"{:?}: have {} pingbacks scheduled" ,
5283
5280
& self . local_peer,
5284
5281
self . walk_pingbacks. len( )
@@ -5580,6 +5577,13 @@ impl PeerNetwork {
5580
5577
} ;
5581
5578
5582
5579
// update cached burnchain view for /v2/info
5580
+ debug ! (
5581
+ "{:?}: chain view for burn block {} has stacks tip consensus {}" ,
5582
+ & self . local_peer,
5583
+ new_chain_view. burn_block_height,
5584
+ & new_chain_view. rc_consensus_hash
5585
+ ) ;
5586
+
5583
5587
self . chain_view = new_chain_view;
5584
5588
self . chain_view_stable_consensus_hash = new_chain_view_stable_consensus_hash;
5585
5589
}
@@ -5649,7 +5653,7 @@ impl PeerNetwork {
5649
5653
. get_last_selected_anchor_block_txid ( ) ?
5650
5654
. unwrap_or ( Txid ( [ 0x00 ; 32 ] ) ) ;
5651
5655
5652
- test_debug ! (
5656
+ debug ! (
5653
5657
"{:?}: chain view is {:?}" ,
5654
5658
& self . get_local_peer( ) ,
5655
5659
& self . chain_view
0 commit comments