From bc725b68d8baf4a95d3e35d37f1bf6db174ca65e Mon Sep 17 00:00:00 2001 From: M1nd3r Date: Thu, 14 Nov 2024 15:42:46 +0100 Subject: [PATCH] chore(core): remove unused session_id from codec_v1 [no changelog] --- core/src/apps/debug/__init__.py | 5 ++--- core/src/trezor/wire/__init__.py | 9 ++++----- core/src/trezor/wire/codec_v1.py | 2 -- core/src/trezor/wire/context.py | 12 ++++-------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/core/src/apps/debug/__init__.py b/core/src/apps/debug/__init__.py index 60f6e0fa247..41c65eb85b0 100644 --- a/core/src/apps/debug/__init__.py +++ b/core/src/apps/debug/__init__.py @@ -360,7 +360,7 @@ async def handle_session(iface: WireInterface) -> None: global DEBUG_CONTEXT - DEBUG_CONTEXT = ctx = context.Context(iface, 0, WIRE_BUFFER_DEBUG) + DEBUG_CONTEXT = ctx = context.Context(iface, WIRE_BUFFER_DEBUG) if storage.layout_watcher: try: @@ -385,9 +385,8 @@ async def handle_session(iface: WireInterface) -> None: msg_type = f"{msg.type} - unknown message type" log.debug( __name__, - "%s:%x receive: <%s>", + "%d receive: <%s>", ctx.iface.iface_num(), - ctx.sid, msg_type, ) diff --git a/core/src/trezor/wire/__init__.py b/core/src/trezor/wire/__init__.py index 90e7ac38541..9023bbd2884 100644 --- a/core/src/trezor/wire/__init__.py +++ b/core/src/trezor/wire/__init__.py @@ -56,7 +56,7 @@ def setup(iface: WireInterface) -> None: """Initialize the wire stack on passed USB interface.""" - loop.schedule(handle_session(iface, codec_v1.SESSION_ID)) + loop.schedule(handle_session(iface)) def wrap_protobuf_load( @@ -109,9 +109,8 @@ async def _handle_single_message(ctx: context.Context, msg: codec_v1.Message) -> msg_type = f"{msg.type} - unknown message type" log.debug( __name__, - "%s:%x receive: <%s>", + "%d receive: <%s>", ctx.iface.iface_num(), - ctx.sid, msg_type, ) @@ -190,8 +189,8 @@ async def _handle_single_message(ctx: context.Context, msg: codec_v1.Message) -> return msg.type in AVOID_RESTARTING_FOR -async def handle_session(iface: WireInterface, session_id: int) -> None: - ctx = context.Context(iface, session_id, WIRE_BUFFER) +async def handle_session(iface: WireInterface) -> None: + ctx = context.Context(iface, WIRE_BUFFER) next_msg: codec_v1.Message | None = None # Take a mark of modules that are imported at this point, so we can diff --git a/core/src/trezor/wire/codec_v1.py b/core/src/trezor/wire/codec_v1.py index 54c0871b999..d4c8aacf840 100644 --- a/core/src/trezor/wire/codec_v1.py +++ b/core/src/trezor/wire/codec_v1.py @@ -15,8 +15,6 @@ _REP_INIT_DATA = const(9) # offset of data in the initial report _REP_CONT_DATA = const(1) # offset of data in the continuation report -SESSION_ID = const(0) - class CodecError(Exception): pass diff --git a/core/src/trezor/wire/context.py b/core/src/trezor/wire/context.py index e45f609849f..10248c871a4 100644 --- a/core/src/trezor/wire/context.py +++ b/core/src/trezor/wire/context.py @@ -60,9 +60,8 @@ class Context: (i.e., wire, debug, single BT connection, etc.) """ - def __init__(self, iface: WireInterface, sid: int, buffer: bytearray) -> None: + def __init__(self, iface: WireInterface, buffer: bytearray) -> None: self.iface = iface - self.sid = sid self.buffer = buffer def read_from_wire(self) -> Awaitable[codec_v1.Message]: @@ -95,9 +94,8 @@ async def read( if __debug__: log.debug( __name__, - "%s:%x expect: %s", + "%d expect: %s", self.iface.iface_num(), - self.sid, expected_type.MESSAGE_NAME if expected_type else expected_types, ) @@ -115,9 +113,8 @@ async def read( if __debug__: log.debug( __name__, - "%s:%x read: %s", + "%d read: %s", self.iface.iface_num(), - self.sid, expected_type.MESSAGE_NAME, ) @@ -131,9 +128,8 @@ async def write(self, msg: protobuf.MessageType) -> None: if __debug__: log.debug( __name__, - "%s:%x write: %s", + "%d write: %s", self.iface.iface_num(), - self.sid, msg.MESSAGE_NAME, )