You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-firmware/core/src/storage/cache.py

37 lines
672 B

from trezor.crypto import random
6 years ago
if False:
from typing import Optional
APP_COMMON_SEED = 0
APP_COMMON_SEED_WITHOUT_PASSPHRASE = 1
APP_CARDANO_ROOT = 2
APP_MONERO_LIVE_REFRESH = 3
_cache_session_id = None # type: Optional[bytes]
_cache = {}
if False:
from typing import Any
def get_session_id() -> bytes:
global _cache_session_id
if not _cache_session_id:
_cache_session_id = random.bytes(32)
return _cache_session_id
def set(key: int, value: Any) -> None:
_cache[key] = value
def get(key: int) -> Any:
return _cache.get(key)
def clear() -> None:
global _cache_session_id
_cache_session_id = None
_cache.clear()