parent
65d988471a
commit
051dc2f039
|
|
@ -9,16 +9,19 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.2"
|
bitflags = "1.2"
|
||||||
bytes = "0.4"
|
|
||||||
rand = "0.7"
|
|
||||||
byteorder = "1.3"
|
byteorder = "1.3"
|
||||||
|
bytes = "0.4"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
serde = { version = "1", features = ["serde_derive"] }
|
serde = { version = "1", features = ["serde_derive"] }
|
||||||
pin-project = "0.4"
|
pin-project = "0.4"
|
||||||
|
hex = "0.4"
|
||||||
# indexmap has rayon support for parallel iteration,
|
# indexmap has rayon support for parallel iteration,
|
||||||
# which we don't use, so disable it to drop the dependencies.
|
# which we don't use, so disable it to drop the dependencies.
|
||||||
indexmap = { version = "1.2", default-features = false }
|
indexmap = { version = "1.2", default-features = false }
|
||||||
|
pin-project = "0.4"
|
||||||
|
rand = "0.7"
|
||||||
|
serde = { version = "1", features = ["serde_derive"] }
|
||||||
|
|
||||||
tokio = "=0.2.0-alpha.6"
|
tokio = "=0.2.0-alpha.6"
|
||||||
futures-preview = "=0.3.0-alpha.19"
|
futures-preview = "=0.3.0-alpha.19"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,18 @@
|
||||||
//! Newtype wrappers assigning semantic meaning to primitive types.
|
//! Newtype wrappers assigning semantic meaning to primitive types.
|
||||||
|
|
||||||
|
use hex;
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
/// A magic number identifying the network.
|
/// A magic number identifying the network.
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||||
pub struct Magic(pub [u8; 4]);
|
pub struct Magic(pub [u8; 4]);
|
||||||
|
|
||||||
|
impl fmt::Debug for Magic {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
f.debug_tuple("Magic").field(&hex::encode(&self.0)).finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A protocol version number.
|
/// A protocol version number.
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct Version(pub u32);
|
pub struct Version(pub u32);
|
||||||
|
|
@ -34,3 +43,15 @@ impl Default for Nonce {
|
||||||
Self(thread_rng().gen())
|
Self(thread_rng().gen())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
|
||||||
|
use crate::constants::magics;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn magic_debug() {
|
||||||
|
assert_eq!(format!("{:?}", magics::MAINNET), "Magic(\"24e92764\")");
|
||||||
|
assert_eq!(format!("{:?}", magics::TESTNET), "Magic(\"fa1af9bf\")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue