1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-09 06:50:58 +00:00

fixup! refactor(core): abstract cache and context [no changelog]

This commit is contained in:
M1nd3r 2024-11-20 10:34:07 +01:00
parent f180c32bb8
commit 91d477c3c4
3 changed files with 2 additions and 20 deletions

View File

@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, Awaitable, Container, overload
from typing import TYPE_CHECKING, Awaitable, Container
from storage import cache_codec
from storage.cache_common import DataCache, InvalidSessionError
@ -27,7 +27,6 @@ class CodecContext(Context):
iface: WireInterface,
buffer: bytearray,
) -> None:
self.iface = iface
self.buffer = buffer
super().__init__(iface)
@ -35,20 +34,6 @@ class CodecContext(Context):
"""Read a whole message from the wire without parsing it."""
return codec_v1.read_message(self.iface, self.buffer)
if TYPE_CHECKING:
@overload
async def read(
self, expected_types: Container[int]
) -> protobuf.MessageType: ...
@overload
async def read(
self, expected_types: Container[int], expected_type: type[LoadedMessageType]
) -> LoadedMessageType: ...
reading: bool = False
async def read(
self,
expected_types: Container[int],

View File

@ -26,7 +26,7 @@ def wrap_protobuf_load(
expected_type: type[LoadedMessageType],
) -> LoadedMessageType:
try:
if __debug__:
if __debug__ and utils.EMULATOR:
log.debug(
__name__,
"Buffer to be parsed to a LoadedMessage: %s",

View File

@ -22,9 +22,6 @@ class Message:
self.data = message_data
self.type = message_type
def to_bytes(self) -> bytes:
return self.type.to_bytes(2, "big") + self.data
class Context:
channel_id: bytes