mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-19 23:19:28 +00:00
remove second hash cache, type as Bytes32
This commit is contained in:
parent
230e5ce345
commit
951c552ecc
@ -1,17 +1,9 @@
|
||||
from hashlib import sha256
|
||||
from typing import Dict, Union
|
||||
from remerkleable.byte_arrays import Bytes32
|
||||
from typing import Union
|
||||
|
||||
ZERO_BYTES32 = b'\x00' * 32
|
||||
|
||||
|
||||
def _hash(x: Union[bytes, bytearray, memoryview]) -> bytes:
|
||||
return sha256(x).digest()
|
||||
|
||||
|
||||
hash_cache: Dict[bytes, bytes] = {}
|
||||
|
||||
|
||||
def hash(x: bytes) -> bytes:
|
||||
if x in hash_cache:
|
||||
return hash_cache[x]
|
||||
return _hash(x)
|
||||
def hash(x: Union[bytes, bytearray, memoryview]) -> Bytes32:
|
||||
return Bytes32(sha256(x).digest())
|
||||
|
Loading…
x
Reference in New Issue
Block a user