Merge pull request #538 from ethereum/vbuterin-patch-1
SSZ list Merkle hashing change
This commit is contained in:
commit
2ac420c5ea
|
@ -390,7 +390,7 @@ Return the hash of the serialization of the value.
|
||||||
|
|
||||||
#### List/Vectors
|
#### List/Vectors
|
||||||
|
|
||||||
First, we define some helpers and then the Merkle tree function.
|
First, we define the Merkle tree function.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
# Merkle tree hash of a list of homogenous, non-empty items
|
# Merkle tree hash of a list of homogenous, non-empty items
|
||||||
|
@ -406,7 +406,10 @@ def merkle_hash(lst):
|
||||||
items_per_chunk = SSZ_CHUNK_SIZE // len(lst[0])
|
items_per_chunk = SSZ_CHUNK_SIZE // len(lst[0])
|
||||||
|
|
||||||
# Build a list of chunks based on the number of items in the chunk
|
# Build a list of chunks based on the number of items in the chunk
|
||||||
chunkz = [b''.join(lst[i:i+items_per_chunk]) for i in range(0, len(lst), items_per_chunk)]
|
chunkz = [
|
||||||
|
zpad(b''.join(lst[i:i + items_per_chunk]), SSZ_CHUNK_SIZE)
|
||||||
|
for i in range(0, len(lst), items_per_chunk)
|
||||||
|
]
|
||||||
else:
|
else:
|
||||||
# Leave large items alone
|
# Leave large items alone
|
||||||
chunkz = lst
|
chunkz = lst
|
||||||
|
|
Loading…
Reference in New Issue