o
    ¢ØÆhð  ã                   @   s.   d dl mZ ddlmZmZ G dd„ dƒZdS )é    )ÚUnioné   )Ú
BackendAPIÚPreImageAPIc                   @   s†   e Zd Zdeddfdd„Zdeeef defdd„Zdeeef de	fd	d
„Z
deeef defdd„Zdeeef de	fdd„ZdS )Ú	Keccak256ÚbackendÚreturnNc                 C   s   || _ | j| _| j| _d S ©N)Ú_backendÚ_hasher_first_runÚhasherÚ_preimage_first_runÚpreimage)Úselfr   © r   úZ/var/www/html/HyperOracle/crypto_trader/venv/lib/python3.10/site-packages/eth_hash/main.pyÚ__init__   s   zKeccak256.__init__Úin_datac                 C   s.   | j  |¡}| j j}|dƒdksJ ‚|| _|S )zô
        Validate, on first-run, that the hasher backend is valid.

        After first run, replace this with the new hasher method.
        This is a bit of a hacky way to minimize overhead on hash calls after
        this first one.
        ó    s    ÅÒF†÷#<’~}²ÜÇÀå ¶SÊ‚';{úØ]…¤p)r
   Ú	keccak256r   )r   r   ÚresultÚ
new_hasherr   r   r   r      s   
ÿzKeccak256._hasher_first_runc                 C   s   | j  |¡}| j j| _|S r	   )r
   r   )r   r   r   r   r   r   r   $   s   
zKeccak256._preimage_first_runr   c                 C   ó*   t |ttfƒstdt|ƒ› �ƒ‚|  |¡S ©Nz@Can only compute the hash of `bytes` or `bytearray` values, not )Ú
isinstanceÚ	bytearrayÚbytesÚ	TypeErrorÚreprr   ©r   r   r   r   r   Ú__call__+   s   ÿÿ
zKeccak256.__call__c                 C   r   r   )r   r   r   r   r   r   r   r   r   r   Únew4   s   ÿÿ
zKeccak256.new)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   r   r    r!   r   r   r   r   r      s    	r   N)Útypingr   Úabcr   r   r   r   r   r   r   Ú<module>   s    