diff --git a/Cargo.toml b/Cargo.toml index 04c64569..5937b598 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,3 +9,9 @@ members = [ "zebra-client", "zebrad", ] + +[profile.dev] +panic = "abort" + +[profile.release] +panic = "abort" \ No newline at end of file diff --git a/zebra-network/src/config.rs b/zebra-network/src/config.rs index a71c21ce..d8e47ade 100644 --- a/zebra-network/src/config.rs +++ b/zebra-network/src/config.rs @@ -1,7 +1,7 @@ use std::{ net::{SocketAddr, ToSocketAddrs}, string::String, - time::Duration, + time::Duration, collections::HashSet, }; use zebra_chain::Network; @@ -21,11 +21,11 @@ pub struct Config { /// A list of initial peers for the peerset when operating on /// mainnet. - pub initial_mainnet_peers: Vec, + pub initial_mainnet_peers: HashSet, /// A list of initial peers for the peerset when operating on /// testnet. - pub initial_testnet_peers: Vec, + pub initial_testnet_peers: HashSet, /// The outgoing request buffer size for the peer set. pub peerset_request_buffer_size: usize, @@ -49,16 +49,16 @@ pub struct Config { } impl Config { - fn parse_peers(peers: Vec) -> Vec { + fn parse_peers(peers: HashSet) -> HashSet { peers .iter() .flat_map(|s| s.to_socket_addrs()) .flatten() - .collect::>() + .collect() } /// Get the initial seed peers based on the configured network. - pub fn initial_peers(&self) -> Vec { + pub fn initial_peers(&self) -> HashSet { match self.network { Network::Mainnet => Config::parse_peers(self.initial_mainnet_peers.clone()), Network::Testnet => Config::parse_peers(self.initial_testnet_peers.clone()), diff --git a/zebra-network/src/peer_set/initialize.rs b/zebra-network/src/peer_set/initialize.rs index 7dc2c1b4..1327d50b 100644 --- a/zebra-network/src/peer_set/initialize.rs +++ b/zebra-network/src/peer_set/initialize.rs @@ -148,7 +148,7 @@ where /// the results over `tx`. #[instrument(skip(initial_peers, connector, tx))] async fn add_initial_peers( - initial_peers: Vec, + initial_peers: std::collections::HashSet, connector: S, mut tx: mpsc::Sender, ) where diff --git a/zebra-network/src/peer_set/set.rs b/zebra-network/src/peer_set/set.rs index 9930657f..eeedb98e 100644 --- a/zebra-network/src/peer_set/set.rs +++ b/zebra-network/src/peer_set/set.rs @@ -163,6 +163,7 @@ where self.ready_services.insert(key, svc); } Poll::Ready(Some(Err((key, UnreadyError::Canceled)))) => { + trace!(?key, "service was canceled"); debug_assert!(!self.cancel_handles.contains_key(&key)) } Poll::Ready(Some(Err((key, UnreadyError::Inner(e))))) => { diff --git a/zebrad/src/application.rs b/zebrad/src/application.rs index 5291b9a2..84a3eb7a 100644 --- a/zebrad/src/application.rs +++ b/zebrad/src/application.rs @@ -108,7 +108,9 @@ impl Application for ZebradApp { /// Get logging configuration from command-line options fn tracing_config(&self, command: &EntryPoint) -> trace::Config { - if command.verbose { + if let Ok(env) = std::env::var("ZEBRAD_LOG") { + trace::Config::from(env) + } else if command.verbose { trace::Config::verbose() } else { trace::Config::default() diff --git a/zebrad/src/commands/connect.rs b/zebrad/src/commands/connect.rs index a599f009..a76f8808 100644 --- a/zebrad/src/commands/connect.rs +++ b/zebrad/src/commands/connect.rs @@ -60,7 +60,7 @@ impl ConnectCmd { // Use a different listen addr so that we don't conflict with another local node. config.listen_addr = "127.0.0.1:38233".parse().unwrap(); // Connect only to the specified peer. - config.initial_mainnet_peers = vec![self.addr.to_string()]; + config.initial_mainnet_peers.insert(self.addr.to_string()); let (mut peer_set, _address_book) = zebra_network::init(config, node).await; let mut retry_peer_set =