mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
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:
parent
cbc17ff5f7
commit
52ea906b61
2 changed files with 2 additions and 8 deletions
|
@ -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,
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue