diff --git a/zebra-network/src/constants.rs b/zebra-network/src/constants.rs index 7efea3aa9..b7eaab841 100644 --- a/zebra-network/src/constants.rs +++ b/zebra-network/src/constants.rs @@ -1,6 +1,7 @@ //! Definitions of constants. -use crate::types::*; +// XXX should these constants be split into protocol also? +use crate::protocol::types::*; /// The User-Agent string provided by the node. pub const USER_AGENT: &'static str = "Zebra v2.0.0-alpha.0"; diff --git a/zebra-network/src/lib.rs b/zebra-network/src/lib.rs index efd2ab455..46600cc69 100644 --- a/zebra-network/src/lib.rs +++ b/zebra-network/src/lib.rs @@ -11,7 +11,6 @@ mod network; pub use network::Network; pub mod protocol; -pub mod types; // XXX make this private once connect is removed pub mod meta_addr; diff --git a/zebra-network/src/meta_addr.rs b/zebra-network/src/meta_addr.rs index 2933543eb..8af5fb387 100644 --- a/zebra-network/src/meta_addr.rs +++ b/zebra-network/src/meta_addr.rs @@ -3,11 +3,14 @@ use chrono::{DateTime, Utc}; use std::net::SocketAddr; -use crate::types::Services; +use crate::protocol::types::Services; /// An address with metadata on its advertised services and last-seen time. /// /// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#Network_address) +// XXX determine whether we will use this struct in *our* networking handling +// code, or just in the definitions of the networking protocol (in which case +// it should live in the protocol submodule) #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct MetaAddr { /// The peer's address. diff --git a/zebra-network/src/network.rs b/zebra-network/src/network.rs index c211e2a1e..81d9ffe6e 100644 --- a/zebra-network/src/network.rs +++ b/zebra-network/src/network.rs @@ -1,4 +1,4 @@ -use crate::{constants::magics, types::Magic}; +use crate::{constants::magics, protocol::types::Magic}; /// An enum describing the possible network choices. #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] diff --git a/zebra-network/src/protocol.rs b/zebra-network/src/protocol.rs index 21dabde18..f86d644e4 100644 --- a/zebra-network/src/protocol.rs +++ b/zebra-network/src/protocol.rs @@ -2,3 +2,4 @@ pub mod codec; pub mod message; +pub mod types; diff --git a/zebra-network/src/protocol/codec.rs b/zebra-network/src/protocol/codec.rs index 42e645353..6071ec3b9 100644 --- a/zebra-network/src/protocol/codec.rs +++ b/zebra-network/src/protocol/codec.rs @@ -13,9 +13,9 @@ use zebra_chain::{ types::{BlockHeight, Sha256dChecksum}, }; -use crate::{constants, types::*, Network}; +use crate::{constants, Network}; -use super::message::Message; +use super::{message::Message, types::*}; /// The length of a Bitcoin message header. const HEADER_LEN: usize = 24usize; diff --git a/zebra-network/src/protocol/message.rs b/zebra-network/src/protocol/message.rs index ebf32cd0f..c25f8c93d 100644 --- a/zebra-network/src/protocol/message.rs +++ b/zebra-network/src/protocol/message.rs @@ -8,7 +8,8 @@ use zebra_chain::block::Block; use zebra_chain::{transaction::Transaction, types::BlockHeight}; use crate::meta_addr::MetaAddr; -use crate::types::*; + +use super::types::*; /// A Bitcoin-like network message for the Zcash protocol. /// diff --git a/zebra-network/src/types.rs b/zebra-network/src/protocol/types.rs similarity index 100% rename from zebra-network/src/types.rs rename to zebra-network/src/protocol/types.rs diff --git a/zebrad/src/commands/connect.rs b/zebrad/src/commands/connect.rs index 583663f0c..aa4f4ab17 100644 --- a/zebrad/src/commands/connect.rs +++ b/zebrad/src/commands/connect.rs @@ -59,8 +59,7 @@ impl ConnectCmd { use zebra_chain::types::BlockHeight; use zebra_network::{ constants, - protocol::{codec::*, message::*}, - types::*, + protocol::{codec::*, message::*, types::*}, Network, };