Remove unused impl ZcashDeserialize for Height (#6139)
This commit is contained in:
parent
fc955152b7
commit
a8370a8eda
|
@ -1,14 +1,8 @@
|
||||||
//! Block height.
|
//! Block height.
|
||||||
|
|
||||||
use crate::serialization::{SerializationError, ZcashDeserialize};
|
use std::ops::{Add, Sub};
|
||||||
|
|
||||||
use byteorder::{LittleEndian, ReadBytesExt};
|
use crate::serialization::SerializationError;
|
||||||
|
|
||||||
use std::{
|
|
||||||
convert::TryFrom,
|
|
||||||
io,
|
|
||||||
ops::{Add, Sub},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// The length of the chain back to the genesis block.
|
/// The length of the chain back to the genesis block.
|
||||||
///
|
///
|
||||||
|
@ -19,6 +13,11 @@ use std::{
|
||||||
/// # Invariants
|
/// # Invariants
|
||||||
///
|
///
|
||||||
/// Users should not construct block heights greater than `Height::MAX`.
|
/// Users should not construct block heights greater than `Height::MAX`.
|
||||||
|
///
|
||||||
|
/// # Consensus
|
||||||
|
///
|
||||||
|
/// There are multiple formats for serializing a height, so we don't implement
|
||||||
|
/// `ZcashSerialize` or `ZcashDeserialize` for `Height`.
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
||||||
pub struct Height(pub u32);
|
pub struct Height(pub u32);
|
||||||
|
|
||||||
|
@ -132,18 +131,6 @@ impl Sub<i32> for Height {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ZcashDeserialize for Height {
|
|
||||||
fn zcash_deserialize<R: io::Read>(mut reader: R) -> Result<Self, SerializationError> {
|
|
||||||
let height = reader.read_u32::<LittleEndian>()?;
|
|
||||||
|
|
||||||
if height > Self::MAX.0 {
|
|
||||||
return Err(SerializationError::Parse("Height exceeds maximum height"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Self(height))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn operator_tests() {
|
fn operator_tests() {
|
||||||
let _init_guard = zebra_test::init();
|
let _init_guard = zebra_test::init();
|
||||||
|
|
Loading…
Reference in New Issue