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)
This commit is contained in:
Antioch Peverell 2019-12-02 12:35:17 +00:00 committed by GitHub
parent cbc17ff5f7
commit 52ea906b61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 8 deletions

View file

@ -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<HeaderVersion> 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::<Utc>::from_utc(NaiveDateTime::from_timestamp(0, 0), Utc),
prev_hash: ZERO_HASH,

View file

@ -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.