fix: Rename the light client hash field

This commit is contained in:
teor 2020-07-27 20:45:29 +10:00
parent faac50697c
commit 53ce01fd23
3 changed files with 10 additions and 13 deletions

View File

@ -38,15 +38,12 @@ pub struct BlockHeader {
/// [Sapling and Blossom] The root LEBS2OSP256(rt) of the Sapling note /// [Sapling and Blossom] The root LEBS2OSP256(rt) of the Sapling note
/// commitment tree corresponding to the final Sapling treestate of /// commitment tree corresponding to the final Sapling treestate of
/// this block. /// this block.
/// [Heartwood onward] The root of a Merkle Mountain Range tree, which /// [Heartwood activation block] All zeroes. See ZIP-221 for details.
/// commits to various features of the chain's history, including the /// [After Heartwood activation block] The root of a Merkle Mountain
/// Sapling commitment tree. This commitment supports the FlyClient /// Range tree, which commits to various features of the chain's
/// protocol. See ZIP-221 for details. /// history, including the Sapling commitment tree. This commitment
// TODO: /// supports the FlyClient protocol. See ZIP-221 for details.
// - replace with an unspecified HistoryRootHash type? pub light_client_root_hash: [u8; 32],
// Note that the NetworkUpgrade list is in zebra-consensus, so we can't
// parse this field into a HistoryRootHash enum in zebra-chain.
pub history_root_hash: [u8; 32],
/// The block timestamp is a Unix epoch time (UTC) when the miner /// The block timestamp is a Unix epoch time (UTC) when the miner
/// started hashing the header (according to the miner). /// started hashing the header (according to the miner).

View File

@ -18,7 +18,7 @@ impl ZcashSerialize for BlockHeader {
writer.write_u32::<LittleEndian>(self.version)?; writer.write_u32::<LittleEndian>(self.version)?;
self.previous_block_hash.zcash_serialize(&mut writer)?; self.previous_block_hash.zcash_serialize(&mut writer)?;
writer.write_all(&self.merkle_root_hash.0[..])?; writer.write_all(&self.merkle_root_hash.0[..])?;
writer.write_all(&self.history_root_hash[..])?; writer.write_all(&self.light_client_root_hash[..])?;
// this is a truncating cast, rather than a saturating cast // this is a truncating cast, rather than a saturating cast
// but u32 times are valid until 2106, and our block verification time // but u32 times are valid until 2106, and our block verification time
// checks should detect any truncation. // checks should detect any truncation.
@ -66,7 +66,7 @@ impl ZcashDeserialize for BlockHeader {
version, version,
previous_block_hash: BlockHeaderHash::zcash_deserialize(&mut reader)?, previous_block_hash: BlockHeaderHash::zcash_deserialize(&mut reader)?,
merkle_root_hash: MerkleTreeRootHash(reader.read_32_bytes()?), merkle_root_hash: MerkleTreeRootHash(reader.read_32_bytes()?),
history_root_hash: reader.read_32_bytes()?, light_client_root_hash: reader.read_32_bytes()?,
// This can't panic, because all u32 values are valid `Utc.timestamp`s // This can't panic, because all u32 values are valid `Utc.timestamp`s
time: Utc.timestamp(reader.read_u32::<LittleEndian>()? as i64, 0), time: Utc.timestamp(reader.read_u32::<LittleEndian>()? as i64, 0),
difficulty_threshold: CompactDifficulty(reader.read_u32::<LittleEndian>()?), difficulty_threshold: CompactDifficulty(reader.read_u32::<LittleEndian>()?),

View File

@ -39,7 +39,7 @@ impl Arbitrary for BlockHeader {
version, version,
previous_block_hash, previous_block_hash,
merkle_root_hash, merkle_root_hash,
history_root_hash, light_client_root_hash,
timestamp, timestamp,
difficulty_threshold, difficulty_threshold,
nonce, nonce,
@ -48,7 +48,7 @@ impl Arbitrary for BlockHeader {
version, version,
previous_block_hash, previous_block_hash,
merkle_root_hash, merkle_root_hash,
history_root_hash, light_client_root_hash,
time: Utc.timestamp(timestamp, 0), time: Utc.timestamp(timestamp, 0),
difficulty_threshold, difficulty_threshold,
nonce, nonce,