Safer serialization of base types (#18)

* use MESSAGE_SIZE constant instead of 32
* use Hashed trait in genesis
* safer serialization of Hash
* Hashed of [u8] should send only data to hash function, not length + data
* Safer serialization of Proof
* Safer serialization of Commitment
* Safer serialization of RangeProof
* introduce read_limited_vec instead of potential panic in conversion
This commit is contained in:
GarrickOllivander
2016-12-17 21:44:14 +00:00
committed by Ignotus Peverell
parent 9b5125c553
commit 2e6d3d9fdb
8 changed files with 106 additions and 105 deletions
+4 -4
View File
@@ -111,13 +111,13 @@ impl ser::Writeable for Tip {
impl ser::Readable<Tip> for Tip {
fn read(reader: &mut ser::Reader) -> Result<Tip, ser::Error> {
let height = try!(reader.read_u64());
let last = try!(reader.read_fixed_bytes(32));
let prev = try!(reader.read_fixed_bytes(32));
let last = try!(Hash::read(reader));
let prev = try!(Hash::read(reader));
let line = try!(Lineage::read(reader));
Ok(Tip {
height: height,
last_block_h: Hash::from_vec(last),
prev_block_h: Hash::from_vec(prev),
last_block_h: last,
prev_block_h: prev,
lineage: line,
})
}