Skip to content

Commit

Permalink
Improve logging, cleanup variables and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Oct 21, 2021
1 parent e0f685c commit 2000232
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions zebra-network/src/peer_set/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,19 @@ where
.await
.expect("unexpected panic in spawned initial peers task")
.expect("unexpected error connecting to initial peers");
let initial_peer_count = active_outbound_connections.update_count();
let active_initial_peer_count = active_outbound_connections.update_count();

// We need to await candidates.update() here, because zcashd only sends one
// `addr` message per connection, and if we only have one initial peer we
// need to ensure that its `addr` message is used by the crawler.

info!("Sending initial request for peers");
let _ = candidates.update_initial(initial_peer_count).await;
info!(
?active_initial_peer_count,
"sending initial request for peers"
);
let _ = candidates.update_initial(active_initial_peer_count).await;

// TODO: reduce demand by initial_peer_count (#2902)
// TODO: reduce demand by `active_outbound_connections.update_count()` (#2902)
for _ in 0..config.peerset_initial_target_size {
let _ = demand_tx.try_send(MorePeers);
}
Expand Down Expand Up @@ -582,6 +585,7 @@ where
}

/// Try to connect to `candidate` using `outbound_connector`.
/// Uses `outbound_connection_tracker` to track the active connection count.
///
/// Returns a `HandshakeConnected` action on success, and a
/// `HandshakeFailed` action on error.
Expand Down
4 changes: 2 additions & 2 deletions zebra-network/src/peer_set/limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ pub struct ConnectionClosed;

/// A counter for active connections.
///
/// Creates [`ConnectionTracker`] to track each active connection.
/// Creates a [`ConnectionTracker`] to track each active connection.
/// When these trackers are dropped, the counter gets notified.
pub struct ActiveConnectionCounter {
/// The current number of peers connected to Zebra.
/// The number of peers active peers tracked using this counter.
count: usize,

/// The channel used to send closed connection notifications.
Expand Down

0 comments on commit 2000232

Please sign in to comment.