Commit e67a2382 authored by Yacov Manevich's avatar Yacov Manevich Committed by Gerrit Code Review
Browse files

Merge "[FAB-1700] Determinsitic BlockData hashing"

parents ff571c21 25c888d6
......@@ -18,6 +18,7 @@ package chainconfig
import (
cb ""
......@@ -144,8 +145,8 @@ func (pm *DescriptorImpl) ProposeConfig(configItem *cb.ConfigurationItem) error
return fmt.Errorf("Unmarshaling error for BlockDataHashingStructure: %s", err)
if blockDataHashingStructure.Width == 0 {
return fmt.Errorf("BlockDataHashStructure width must not be zero")
if blockDataHashingStructure.Width != math.MaxUint32 {
return fmt.Errorf("BlockDataHashStructure width only supported at MaxUint32 in this version")
pm.pendingConfig.blockDataHashingStructureWidth = blockDataHashingStructure.Width
......@@ -21,7 +21,6 @@ import (
......@@ -75,12 +74,15 @@ func (b *BlockHeader) Hash() []byte {
return util.ComputeCryptoHash(b.Bytes())
// Bytes returns a deterministically serialized version of the BlockData
// eventually, this should be replaced with a true Merkle tree construction,
// but for the moment, we assume a Merkle tree of infinite width (uint32_max)
// which degrades to a flat hash
func (b *BlockData) Bytes() []byte {
return util.ConcatenateBytes(b.Data...)
// Hash returns the hash of the marshaled representation of the block data.
func (b *BlockData) Hash() []byte {
data, err := proto.Marshal(b) // XXX this is wrong, protobuf is not the right mechanism to serialize for a hash, AND, it is not a MerkleTree hash
if err != nil {
panic("This should never fail and is generally irrecoverable")
return util.ComputeCryptoHash(data)
return util.ComputeCryptoHash(b.Bytes())
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment