From 388beafb65f1968fac728838ccd0850e22a4dca2 Mon Sep 17 00:00:00 2001 From: Antioch Peverell <30642645+antiochp@users.noreply.github.com> Date: Fri, 23 Mar 2018 19:34:50 -0400 Subject: [PATCH] Standardize and cleanup SerializationMode (#856) --- core/src/core/block.rs | 7 +++---- core/src/core/transaction.rs | 2 +- core/src/ser.rs | 5 ----- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/core/src/core/block.rs b/core/src/core/block.rs index 99869e04ea..8b40866206 100644 --- a/core/src/core/block.rs +++ b/core/src/core/block.rs @@ -145,12 +145,11 @@ impl Default for BlockHeader { /// Serialization of a block header impl Writeable for BlockHeader { fn write(&self, writer: &mut W) -> Result<(), ser::Error> { - if writer.serialization_mode() == ser::SerializationMode::Hash { - try!(self.pow.write(writer)); - } else { + if writer.serialization_mode() != ser::SerializationMode::Hash { self.write_pre_pow(writer)?; - self.pow.write(writer)?; } + + self.pow.write(writer)?; Ok(()) } } diff --git a/core/src/core/transaction.rs b/core/src/core/transaction.rs index d97d77de6b..ff38017283 100644 --- a/core/src/core/transaction.rs +++ b/core/src/core/transaction.rs @@ -706,7 +706,7 @@ impl Writeable for Output { self.commit.write(writer)?; // The hash of an output doesn't include the range proof, which // is commit to separately - if writer.serialization_mode() == ser::SerializationMode::Full { + if writer.serialization_mode() != ser::SerializationMode::Hash { writer.write_bytes(&self.proof)? } Ok(()) diff --git a/core/src/ser.rs b/core/src/ser.rs index cbbb1ec3be..5a8b6b4973 100644 --- a/core/src/ser.rs +++ b/core/src/ser.rs @@ -112,11 +112,6 @@ pub enum SerializationMode { Full, /// Serialize the data that defines the object Hash, - /// Serialize everything that a signer of the object should know - SigHash, - /// Serialize for local storage, for instance in the case where - /// an output doesn't wish to store its range proof - Storage, } /// Implementations defined how different numbers and binary structures are