1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-14 11:39:03 +00:00

refactor(core): remove unnecessary protocol abstraction

This commit is contained in:
M1nd3r 2024-04-03 15:33:59 +02:00
parent 739c4180da
commit 8c543f61be
3 changed files with 3 additions and 26 deletions

View File

@ -205,8 +205,6 @@ trezor.wire.errors
import trezor.wire.errors import trezor.wire.errors
trezor.wire.message_handler trezor.wire.message_handler
import trezor.wire.message_handler import trezor.wire.message_handler
trezor.wire.protocol
import trezor.wire.protocol
trezor.wire.protocol_common trezor.wire.protocol_common
import trezor.wire.protocol_common import trezor.wire.protocol_common
trezor.wire.thp trezor.wire.thp

View File

@ -15,8 +15,8 @@ for ButtonRequests. Of course, `context.wait()` transparently works in such situ
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import trezor.wire.protocol as protocol
from trezor import log, loop, protobuf from trezor import log, loop, protobuf
from trezor.wire import codec_v1
from .protocol_common import Context, MessageWithId from .protocol_common import Context, MessageWithId
@ -74,7 +74,7 @@ class CodecContext(Context):
def read_from_wire(self) -> Awaitable[MessageWithId]: def read_from_wire(self) -> Awaitable[MessageWithId]:
"""Read a whole message from the wire without parsing it.""" """Read a whole message from the wire without parsing it."""
return protocol.read_message(self.iface, self.buffer) return codec_v1.read_message(self.iface, self.buffer)
if TYPE_CHECKING: if TYPE_CHECKING:
@ -176,7 +176,7 @@ class CodecContext(Context):
msg_session_id = None msg_session_id = None
if self.channel_id is not None: if self.channel_id is not None:
msg_session_id = bytearray(self.channel_id) msg_session_id = bytearray(self.channel_id)
await protocol.write_message( await codec_v1.write_message(
self.iface, self.iface,
MessageWithId( MessageWithId(
message_type=msg.MESSAGE_WIRE_TYPE, message_type=msg.MESSAGE_WIRE_TYPE,

View File

@ -1,21 +0,0 @@
from typing import TYPE_CHECKING
from trezor import utils
from trezor.wire import codec_v1
from trezor.wire.protocol_common import MessageWithId
if TYPE_CHECKING:
from trezorio import WireInterface
async def read_message(iface: WireInterface, buffer: utils.BufferType) -> MessageWithId:
if utils.USE_THP:
raise Exception("THP protocol should be used instead")
return await codec_v1.read_message(iface, buffer)
async def write_message(iface: WireInterface, message: MessageWithId) -> None:
if utils.USE_THP:
raise Exception("THP protocol should be used instead")
await codec_v1.write_message(iface, message.type, message.data)
return