diff --git a/src/consensus/encode.rs b/src/consensus/encode.rs index 9dd0526b..c7788140 100644 --- a/src/consensus/encode.rs +++ b/src/consensus/encode.rs @@ -546,33 +546,6 @@ impl> Decodable for Box<[T]> { } } -// Options (encoded as vectors of length 0 or 1) -impl> Encodable for Option { - #[inline] - fn consensus_encode(&self, s: &mut S) -> Result<(), self::Error> { - match *self { - Some(ref data) => { - 1u8.consensus_encode(s)?; - data.consensus_encode(s)?; - } - None => { 0u8.consensus_encode(s)?; } - } - Ok(()) - } -} - -impl> Decodable for Option { - #[inline] - fn consensus_decode(d: &mut D) -> Result, self::Error> { - let bit: u8 = Decodable::consensus_decode(d)?; - Ok(if bit != 0 { - Some(Decodable::consensus_decode(d)?) - } else { - None - }) - } -} - /// Do a double-SHA256 on some data and return the first 4 bytes fn sha2_checksum(data: &[u8]) -> [u8; 4] { @@ -823,12 +796,6 @@ mod tests { assert_eq!(serialize(&Box::new(1u64)), vec![1u8, 0, 0, 0, 0, 0, 0, 0]); } - #[test] - fn serialize_option_test() { - assert_eq!(serialize(&None::), vec![0]); - assert_eq!(serialize(&Some(0xFFu8)), vec![1, 0xFF]); - } - #[test] fn deserialize_int_test() { // bool @@ -890,16 +857,6 @@ mod tests { assert_eq!(cd.ok(), Some(CheckedData(vec![1u8, 2, 3, 4, 5]))); } - #[test] - fn deserialize_option_test() { - let none: Result, _> = deserialize(&[0u8]); - let good: Result, _> = deserialize(&[1u8, 0xFF]); - let bad: Result, _> = deserialize(&[2u8]); - assert!(bad.is_err()); - assert_eq!(none.ok(), Some(None)); - assert_eq!(good.ok(), Some(Some(0xFF))); - } - #[test] fn deserialize_box_test() { let zero: Result, _> = deserialize(&[0u8]);