From b0ecd019b6bb911e4e0bf6d6bdf947189da4964f Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Tue, 16 Jun 2020 11:02:01 -0700 Subject: [PATCH] apply comments from code review --- zebrad/src/commands.rs | 4 ++-- zebrad/src/commands/start.rs | 30 ++++++++---------------------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/zebrad/src/commands.rs b/zebrad/src/commands.rs index d02a8117..f7962246 100644 --- a/zebrad/src/commands.rs +++ b/zebrad/src/commands.rs @@ -8,7 +8,7 @@ mod start; mod version; use self::{ - config::ConfigCmd, connect::ConnectCmd, revhex::RevhexCmd, seed::SeedCmd, start::StartArgs, + config::ConfigCmd, connect::ConnectCmd, revhex::RevhexCmd, seed::SeedCmd, start::StartCmd, version::VersionCmd, }; use crate::config::ZebradConfig; @@ -45,7 +45,7 @@ pub enum ZebradCmd { /// The `start` subcommand #[options(help = "start the application")] - Start(StartArgs), + Start(StartCmd), /// The `version` subcommand #[options(help = "display version information")] diff --git a/zebrad/src/commands/start.rs b/zebrad/src/commands/start.rs index 23c8a5a4..dc5e7fdb 100644 --- a/zebrad/src/commands/start.rs +++ b/zebrad/src/commands/start.rs @@ -39,20 +39,13 @@ static GENESIS: BlockHeaderHash = BlockHeaderHash([ /// `start` subcommand #[derive(Command, Debug, Options)] -pub struct StartArgs { +pub struct StartCmd { /// Filter strings #[options(free)] filters: Vec, - - /// The address of the node to connect to. - #[options( - help = "The address of the node to connect to.", - default = "127.0.0.1:8233" - )] - addr: std::net::SocketAddr, } -impl StartArgs { +impl StartCmd { async fn start(&self) -> Result<(), Report> { info!(?self, "begin tower-based peer handling test stub"); @@ -65,12 +58,7 @@ impl StartArgs { 1, ); - let mut config = app_config().network.clone(); - // Use a different listen addr so that we don't conflict with another local node. - config.listen_addr = "127.0.0.1:38233".parse()?; - // Connect only to the specified peer. - config.initial_mainnet_peers.insert(self.addr.to_string()); - + let config = app_config().network.clone(); let state = zebra_state::in_memory::init(); let (peer_set, _address_book) = zebra_network::init(config, node).await; let retry_peer_set = tower::retry::Retry::new(zebra_network::RetryErrors, peer_set.clone()); @@ -78,7 +66,7 @@ impl StartArgs { let mut downloaded_block_heights = BTreeSet::::new(); downloaded_block_heights.insert(BlockHeight(0)); - let mut connect = ZebraNode { + let mut connect = Core { retry_peer_set, peer_set, state, @@ -92,11 +80,9 @@ impl StartArgs { } } -impl Runnable for StartArgs { +impl Runnable for StartCmd { /// Start the application. fn run(&self) { - info!(connect.addr = ?self.addr); - let rt = app_writer() .state_mut() .components @@ -119,7 +105,7 @@ impl Runnable for StartArgs { } } -impl config::Override for StartArgs { +impl config::Override for StartCmd { // Process the given command line options, overriding settings from // a configuration file using explicit flags taken from command-line // arguments. @@ -132,7 +118,7 @@ impl config::Override for StartArgs { } } -struct ZebraNode +struct Core where ZN: Service, { @@ -145,7 +131,7 @@ where downloaded_block_heights: BTreeSet, } -impl ZebraNode +impl Core where ZN: Service + Send