diff --git a/zebra-network/src/meta_addr.rs b/zebra-network/src/meta_addr.rs index 6f014dbe..3a86e84a 100644 --- a/zebra-network/src/meta_addr.rs +++ b/zebra-network/src/meta_addr.rs @@ -10,7 +10,7 @@ use zebra_chain::serialization::{ ReadZcashExt, SerializationError, WriteZcashExt, ZcashDeserialize, ZcashSerialize, }; -use crate::protocol::types::Services; +use crate::protocol::types::PeerServices; /// An address with metadata on its advertised services and last-seen time. /// @@ -23,7 +23,7 @@ pub struct MetaAddr { /// The peer's address. pub addr: SocketAddr, /// The services advertised by the peer. - pub services: Services, + pub services: PeerServices, /// When the peer was last seen. pub last_seen: DateTime, } @@ -41,7 +41,7 @@ impl ZcashDeserialize for MetaAddr { fn zcash_deserialize(mut reader: R) -> Result { Ok(MetaAddr { last_seen: Utc.timestamp(reader.read_u32::()? as i64, 0), - services: Services(reader.read_u64::()?), + services: PeerServices(reader.read_u64::()?), addr: reader.read_socket_addr()?, }) } diff --git a/zebra-network/src/protocol/codec.rs b/zebra-network/src/protocol/codec.rs index 330d3834..8cff0a49 100644 --- a/zebra-network/src/protocol/codec.rs +++ b/zebra-network/src/protocol/codec.rs @@ -341,14 +341,14 @@ impl Codec { fn read_version(&self, mut reader: R) -> Result { Ok(Message::Version { version: Version(reader.read_u32::()?), - services: Services(reader.read_u64::()?), + services: PeerServices(reader.read_u64::()?), timestamp: Utc.timestamp(reader.read_i64::()?, 0), address_recv: ( - Services(reader.read_u64::()?), + PeerServices(reader.read_u64::()?), reader.read_socket_addr()?, ), address_from: ( - Services(reader.read_u64::()?), + PeerServices(reader.read_u64::()?), reader.read_socket_addr()?, ), nonce: Nonce(reader.read_u64::()?), @@ -505,7 +505,7 @@ mod tests { #[test] fn version_message_round_trip() { use std::net::{IpAddr, Ipv4Addr, SocketAddr}; - let services = Services(0x1); + let services = PeerServices(0x1); let timestamp = Utc.timestamp(1568000000, 0); let rt = Runtime::new().unwrap(); diff --git a/zebra-network/src/protocol/message.rs b/zebra-network/src/protocol/message.rs index 457202a2..290c59b0 100644 --- a/zebra-network/src/protocol/message.rs +++ b/zebra-network/src/protocol/message.rs @@ -48,7 +48,7 @@ pub enum Message { version: Version, /// The network services advertised by the sender. - services: Services, + services: PeerServices, /// The time when the version message was sent. timestamp: DateTime, @@ -57,11 +57,11 @@ pub enum Message { /// advertised network services. /// /// Q: how does the handshake know the remote peer's services already? - address_recv: (Services, net::SocketAddr), + address_recv: (PeerServices, net::SocketAddr), /// The network address of the node sending this message, and its /// advertised network services. - address_from: (Services, net::SocketAddr), + address_from: (PeerServices, net::SocketAddr), /// Node random nonce, randomly generated every time a version /// packet is sent. This nonce is used to detect connections diff --git a/zebra-network/src/protocol/types.rs b/zebra-network/src/protocol/types.rs index 881a6e7e..1d307ede 100644 --- a/zebra-network/src/protocol/types.rs +++ b/zebra-network/src/protocol/types.rs @@ -12,7 +12,7 @@ pub struct Version(pub u32); // Tower provides utilities for service discovery, so this might go // away in the future in favor of that. #[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub struct Services(pub u64); +pub struct PeerServices(pub u64); /// A nonce used in the networking layer to identify messages. #[derive(Copy, Clone, Debug, Eq, PartialEq)] diff --git a/zebrad/src/commands/connect.rs b/zebrad/src/commands/connect.rs index d9652184..4c64c2ac 100644 --- a/zebrad/src/commands/connect.rs +++ b/zebrad/src/commands/connect.rs @@ -70,13 +70,13 @@ impl ConnectCmd { let version = Message::Version { version: constants::CURRENT_VERSION, - services: Services(1), + services: PeerServices(1), timestamp: Utc::now(), - address_recv: (Services(1), self.addr), + address_recv: (PeerServices(1), self.addr), // We just make something up because at this stage the `connect` command // doesn't run a server or anything -- will the zcashd respond on the // same tcp connection or try to open one to the bogus address below? - address_from: (Services(1), "127.0.0.1:9000".parse().unwrap()), + address_from: (PeerServices(1), "127.0.0.1:9000".parse().unwrap()), nonce: Nonce(1), user_agent: "Zebra Connect".to_owned(), start_height: BlockHeight(0),