Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
zistvan-public
StreamChain Prototype
Commits
e67a2382
Commit
e67a2382
authored
Feb 02, 2017
by
Yacov Manevich
Committed by
Gerrit Code Review
Feb 02, 2017
Browse files
Merge "[FAB-1700] Determinsitic BlockData hashing"
parents
ff571c21
25c888d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
common/chainconfig/chainconfig.go
View file @
e67a2382
...
...
@@ -18,6 +18,7 @@ package chainconfig
import
(
"fmt"
"math"
"github.com/hyperledger/fabric/common/util"
cb
"github.com/hyperledger/fabric/protos/common"
...
...
@@ -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
...
...
protos/common/block.go
View file @
e67a2382
...
...
@@ -21,7 +21,6 @@ import (
"fmt"
"math"
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/common/util"
)
...
...
@@ -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
())
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment