mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-25 17:09:44 +00:00
docs(core): add and modify docs to context and cache
[no changelog]
This commit is contained in:
parent
8c6ed70389
commit
f431265736
@ -16,6 +16,11 @@ SESSION_ID_LENGTH = const(32)
|
||||
|
||||
|
||||
class SessionCache(DataCache):
|
||||
"""
|
||||
A cache for storing values that depend on seed derivation
|
||||
or are specific to a `protocol_v1` session.
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.session_id = bytearray(SESSION_ID_LENGTH)
|
||||
if utils.BITCOIN_ONLY:
|
||||
|
@ -36,6 +36,11 @@ class InvalidSessionError(Exception):
|
||||
|
||||
|
||||
class DataCache:
|
||||
"""
|
||||
A single unit of cache storage, designed to store common-type
|
||||
values efficiently in bytearrays in a sequential manner.
|
||||
"""
|
||||
|
||||
fields: Sequence[int] # field sizes
|
||||
|
||||
def __init__(self) -> None:
|
||||
@ -110,6 +115,11 @@ class DataCache:
|
||||
|
||||
|
||||
class SessionlessCache(DataCache):
|
||||
"""
|
||||
A cache for values that are independent of both
|
||||
passphrase seed derivation and the active session.
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.fields = (
|
||||
64, # APP_COMMON_SEED_WITHOUT_PASSPHRASE
|
||||
|
@ -16,11 +16,7 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
class CodecContext(Context):
|
||||
"""Wire context.
|
||||
|
||||
Represents USB communication inside a particular session on a particular interface
|
||||
(i.e., wire, debug, single BT connection, etc.)
|
||||
"""
|
||||
""" "Wire context" for `protocol_v1`."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -53,7 +53,7 @@ WIRE_BUFFER = bytearray(_PROTOBUF_BUFFER_SIZE)
|
||||
|
||||
|
||||
async def handle_single_message(ctx: Context, msg: Message) -> bool:
|
||||
"""Handle a message that was loaded from USB by the caller.
|
||||
"""Handle a message that was loaded from a WireInterface by the caller.
|
||||
|
||||
Find the appropriate handler, run it and write its result on the wire. In case
|
||||
a problem is encountered at any point, write the appropriate error on the wire.
|
||||
|
@ -24,6 +24,13 @@ class Message:
|
||||
|
||||
|
||||
class Context:
|
||||
"""Wire context.
|
||||
|
||||
Represents communication between the Trezor device and a host within
|
||||
a specific session over a particular interface (i.e., wire, debug,
|
||||
single Bluetooth connection, etc.).
|
||||
"""
|
||||
|
||||
channel_id: bytes
|
||||
|
||||
def __init__(self, iface: WireInterface, channel_id: bytes | None = None) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user