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 hashlib import sha256
|
||||||
from typing import Dict, Union
|
from remerkleable.byte_arrays import Bytes32
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
ZERO_BYTES32 = b'\x00' * 32
|
ZERO_BYTES32 = b'\x00' * 32
|
||||||
|
|
||||||
|
|
||||||
def _hash(x: Union[bytes, bytearray, memoryview]) -> bytes:
|
def hash(x: Union[bytes, bytearray, memoryview]) -> Bytes32:
|
||||||
return sha256(x).digest()
|
return Bytes32(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)
|
|
||||||
|
|
Loading…
Reference in New Issue