Standardize and cleanup SerializationMode (#856)

This commit is contained in:
Antioch Peverell 2018-03-23 19:34:50 -04:00 committed by Ignotus Peverell
parent 7a8d6147f4
commit 388beafb65
3 changed files with 4 additions and 10 deletions

View file

@ -145,12 +145,11 @@ impl Default for BlockHeader {
/// Serialization of a block header /// Serialization of a block header
impl Writeable for BlockHeader { impl Writeable for BlockHeader {
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ser::Error> { fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ser::Error> {
if writer.serialization_mode() == ser::SerializationMode::Hash { if writer.serialization_mode() != ser::SerializationMode::Hash {
try!(self.pow.write(writer));
} else {
self.write_pre_pow(writer)?; self.write_pre_pow(writer)?;
self.pow.write(writer)?;
} }
self.pow.write(writer)?;
Ok(()) Ok(())
} }
} }

View file

@ -706,7 +706,7 @@ impl Writeable for Output {
self.commit.write(writer)?; self.commit.write(writer)?;
// The hash of an output doesn't include the range proof, which // The hash of an output doesn't include the range proof, which
// is commit to separately // is commit to separately
if writer.serialization_mode() == ser::SerializationMode::Full { if writer.serialization_mode() != ser::SerializationMode::Hash {
writer.write_bytes(&self.proof)? writer.write_bytes(&self.proof)?
} }
Ok(()) Ok(())

View file

@ -112,11 +112,6 @@ pub enum SerializationMode {
Full, Full,
/// Serialize the data that defines the object /// Serialize the data that defines the object
Hash, 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 /// Implementations defined how different numbers and binary structures are