From d11c85dae1b5e27ef721432a4ae8ac7b10696764 Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Tue, 29 Nov 2016 18:42:43 -0800 Subject: [PATCH] Fixed missing previous in block header. --- core/src/core/block.rs | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/core/src/core/block.rs b/core/src/core/block.rs index af324c7a..c2750f46 100644 --- a/core/src/core/block.rs +++ b/core/src/core/block.rs @@ -101,21 +101,21 @@ impl Readable for BlockHeader { for n in 0..PROOFSIZE { pow[n] = try!(reader.read_u32()); } - Ok(BlockHeader { - height: height, - previous: Hash::from_vec(previous), - timestamp: time::at_utc(time::Timespec { - sec: timestamp, - nsec: 0, - }), - cuckoo_len: cuckoo_len, - target: target, - utxo_merkle: Hash::from_vec(utxo_merkle), - tx_merkle: Hash::from_vec(tx_merkle), - pow: Proof(pow), - nonce: nonce, - }) - } + Ok(BlockHeader { + height: height, + previous: Hash::from_vec(previous), + timestamp: time::at_utc(time::Timespec { + sec: timestamp, + nsec: 0, + }), + cuckoo_len: cuckoo_len, + target: target, + utxo_merkle: Hash::from_vec(utxo_merkle), + tx_merkle: Hash::from_vec(tx_merkle), + pow: Proof(pow), + nonce: nonce, + }) + } } /// A block as expressed in the MimbleWimble protocol. The reward is @@ -157,14 +157,14 @@ impl Writeable for Block { /// from a binary stream. impl Readable for Block { fn read(reader: &mut Reader) -> Result { - let header = try!(BlockHeader::read(reader)); + let header = try!(BlockHeader::read(reader)); let (input_len, output_len, proof_len) = ser_multiread!(reader, read_u64, read_u64, read_u64); if input_len > MAX_IN_OUT_LEN || output_len > MAX_IN_OUT_LEN || proof_len > MAX_IN_OUT_LEN { - return Err(ser::Error::TooLargeReadErr( - "Too many inputs, outputs or proofs.".to_string())); + return Err(ser::Error::TooLargeReadErr("Too many inputs, outputs or proofs." + .to_string())); } let inputs = try!((0..input_len).map(|_| Input::read(reader)).collect()); @@ -252,6 +252,7 @@ impl Block { header: BlockHeader { height: prev.height + 1, timestamp: time::now(), + previous: prev.hash(), ..Default::default() }, inputs: inputs,