Standardize and cleanup SerializationMode (#856)
This commit is contained in:
committed by
Ignotus Peverell
parent
7a8d6147f4
commit
388beafb65
@@ -145,12 +145,11 @@ impl Default for BlockHeader {
|
||||
/// Serialization of a block header
|
||||
impl Writeable for BlockHeader {
|
||||
fn write<W: Writer>(&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(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(())
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user