Skip to content

Commit

Permalink
chore(core): remove unused session_id from codec_v1
Browse files Browse the repository at this point in the history
[no changelog]
  • Loading branch information
M1nd3r committed Nov 14, 2024
1 parent fc63541 commit bc725b6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
5 changes: 2 additions & 3 deletions core/src/apps/debug/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
)

Expand Down
9 changes: 4 additions & 5 deletions core/src/trezor/wire/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
)

Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions core/src/trezor/wire/codec_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions core/src/trezor/wire/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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,
)

Expand All @@ -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,
)

Expand All @@ -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,
)

Expand Down

0 comments on commit bc725b6

Please sign in to comment.