From 52ea906b6128b554848f62f8c234bfd681d4a8ee Mon Sep 17 00:00:00 2001 From: Antioch Peverell Date: Mon, 2 Dec 2019 12:35:17 +0000 Subject: [PATCH] cleanup HeaderVersion::default() (#3149) * header version now explicit, no "default" version "empty" block can safely have verion 0 as it needs to be set later * default block header uses version 1 * HeaderVersion(1) --- core/src/core/block.rs | 8 +------- core/tests/block.rs | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/core/src/core/block.rs b/core/src/core/block.rs index e1e70f449..28c60ba80 100644 --- a/core/src/core/block.rs +++ b/core/src/core/block.rs @@ -179,12 +179,6 @@ impl Hashed for HeaderEntry { #[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)] pub struct HeaderVersion(pub u16); -impl Default for HeaderVersion { - fn default() -> HeaderVersion { - HeaderVersion(1) - } -} - impl From for u16 { fn from(v: HeaderVersion) -> u16 { v.0 @@ -239,7 +233,7 @@ impl DefaultHashable for BlockHeader {} impl Default for BlockHeader { fn default() -> BlockHeader { BlockHeader { - version: HeaderVersion::default(), + version: HeaderVersion(1), height: 0, timestamp: DateTime::::from_utc(NaiveDateTime::from_timestamp(0, 0), Utc), prev_hash: ZERO_HASH, diff --git a/core/tests/block.rs b/core/tests/block.rs index a1d3b67a9..bea271f21 100644 --- a/core/tests/block.rs +++ b/core/tests/block.rs @@ -211,7 +211,7 @@ fn serialize_deserialize_header_version() { ser::serialize_default(&mut vec1, &1_u16).expect("serialization failed"); let mut vec2 = Vec::new(); - ser::serialize_default(&mut vec2, &HeaderVersion::default()).expect("serialization failed"); + ser::serialize_default(&mut vec2, &HeaderVersion(1)).expect("serialization failed"); // Check that a header_version serializes to a // single u16 value with no extraneous bytes wrapping it.