From cf63f00171c3a600dde4b3361be0458b704af86c Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Fri, 13 Sep 2019 05:28:38 -0700 Subject: [PATCH] Add a Magic type for network magics. --- zebra-network/src/constants.rs | 13 +++++++++++-- zebra-network/src/types.rs | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/zebra-network/src/constants.rs b/zebra-network/src/constants.rs index ce97177e1..0b543154c 100644 --- a/zebra-network/src/constants.rs +++ b/zebra-network/src/constants.rs @@ -2,5 +2,14 @@ use crate::types::*; -/// The Zcash version used on mainnet. -pub const ZCASH_VERSION: Version = Version(170_007); +/// The Zcash network protocol version used on mainnet. +pub const CURRENT_VERSION: Version = Version(170_007); + +/// Magic numbers used to identify different Zcash networks. +pub mod magics { + use super::*; + /// The production mainnet. + pub const MAINNET: Magic = Magic(0x6427e924); + /// The testnet. + pub const TESTNET: Magic = Magic(0xbff91afa); +} \ No newline at end of file diff --git a/zebra-network/src/types.rs b/zebra-network/src/types.rs index 6325a44ae..996f16bd6 100644 --- a/zebra-network/src/types.rs +++ b/zebra-network/src/types.rs @@ -1,8 +1,9 @@ //! Newtype wrappers assigning semantic meaning to primitive types. -use std::net::SocketAddr; +/// A magic number identifying the network. +pub struct Magic(pub u32); -/// A protocol version magic number. +/// A protocol version number. pub struct Version(pub u32); /// Bitfield of features to be enabled for this connection.