diff --git a/zebra-network/Cargo.toml b/zebra-network/Cargo.toml index 24fced64..d5d68a8a 100644 --- a/zebra-network/Cargo.toml +++ b/zebra-network/Cargo.toml @@ -7,6 +7,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +rand = "0.7" byteorder = "1.3" chrono = "0.4" failure = "0.1" diff --git a/zebra-network/src/types.rs b/zebra-network/src/types.rs index d4d98ae7..881a6e7e 100644 --- a/zebra-network/src/types.rs +++ b/zebra-network/src/types.rs @@ -17,3 +17,10 @@ pub struct Services(pub u64); /// A nonce used in the networking layer to identify messages. #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct Nonce(pub u64); + +impl Default for Nonce { + fn default() -> Self { + use rand::{thread_rng, Rng}; + Self(thread_rng().gen()) + } +}