diff --git a/core/src/storage/cache_codec.py b/core/src/storage/cache_codec.py index 9bc193f5ae..ac5bb7d4d2 100644 --- a/core/src/storage/cache_codec.py +++ b/core/src/storage/cache_codec.py @@ -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: diff --git a/core/src/storage/cache_common.py b/core/src/storage/cache_common.py index 9026753be5..01145cc8c7 100644 --- a/core/src/storage/cache_common.py +++ b/core/src/storage/cache_common.py @@ -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 diff --git a/core/src/trezor/wire/codec/codec_context.py b/core/src/trezor/wire/codec/codec_context.py index c664124187..2934a7f170 100644 --- a/core/src/trezor/wire/codec/codec_context.py +++ b/core/src/trezor/wire/codec/codec_context.py @@ -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, diff --git a/core/src/trezor/wire/message_handler.py b/core/src/trezor/wire/message_handler.py index 2593d4ddc7..c41f1a3aea 100644 --- a/core/src/trezor/wire/message_handler.py +++ b/core/src/trezor/wire/message_handler.py @@ -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. diff --git a/core/src/trezor/wire/protocol_common.py b/core/src/trezor/wire/protocol_common.py index cf01e91cdd..4cb56e87a7 100644 --- a/core/src/trezor/wire/protocol_common.py +++ b/core/src/trezor/wire/protocol_common.py @@ -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: