1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-02-16 09:32:00 +00:00

core: import some modules lazily to save memory

This commit is contained in:
Jan Pochyla 2019-05-20 15:52:24 +02:00
parent 875579867e
commit d56de2c5fe
2 changed files with 9 additions and 7 deletions

View File

@ -4,12 +4,9 @@ if not __debug__:
halt("debug mode inactive") halt("debug mode inactive")
if __debug__: if __debug__:
from trezor import loop, utils from trezor import config, loop, utils
from trezor.messages import MessageType from trezor.messages import MessageType
from trezor.messages.DebugLinkState import DebugLinkState
from trezor.ui import confirm, swipe
from trezor.wire import register, protobuf_workflow from trezor.wire import register, protobuf_workflow
from apps.common import storage, mnemonic
reset_internal_entropy = None reset_internal_entropy = None
reset_current_words = None reset_current_words = None
@ -20,6 +17,8 @@ if __debug__:
input_signal = loop.signal() input_signal = loop.signal()
async def dispatch_DebugLinkDecision(ctx, msg): async def dispatch_DebugLinkDecision(ctx, msg):
from trezor.ui import confirm, swipe
if msg.yes_no is not None: if msg.yes_no is not None:
confirm_signal.send(confirm.CONFIRMED if msg.yes_no else confirm.CANCELLED) confirm_signal.send(confirm.CONFIRMED if msg.yes_no else confirm.CANCELLED)
if msg.up_down is not None: if msg.up_down is not None:
@ -28,6 +27,9 @@ if __debug__:
input_signal.send(msg.input) input_signal.send(msg.input)
async def dispatch_DebugLinkGetState(ctx, msg): async def dispatch_DebugLinkGetState(ctx, msg):
from trezor.messages.DebugLinkState import DebugLinkState
from apps.common import storage, mnemonic
m = DebugLinkState() m = DebugLinkState()
m.mnemonic_secret, m.mnemonic_type = mnemonic.get() m.mnemonic_secret, m.mnemonic_type = mnemonic.get()
m.passphrase_protection = storage.has_passphrase() m.passphrase_protection = storage.has_passphrase()
@ -40,7 +42,7 @@ if __debug__:
def boot(): def boot():
# wipe storage when debug build is used on real hardware # wipe storage when debug build is used on real hardware
if not utils.EMULATOR: if not utils.EMULATOR:
storage.wipe() config.wipe()
register( register(
MessageType.DebugLinkDecision, protobuf_workflow, dispatch_DebugLinkDecision MessageType.DebugLinkDecision, protobuf_workflow, dispatch_DebugLinkDecision

View File

@ -4,8 +4,6 @@ from trezor.messages import FailureType
from trezor.wire import codec_v1 from trezor.wire import codec_v1
from trezor.wire.errors import Error from trezor.wire.errors import Error
from apps.common import seed
# import all errors into namespace, so that `wire.Error` is available elsewhere # import all errors into namespace, so that `wire.Error` is available elsewhere
from trezor.wire.errors import * # isort:skip # noqa: F401,F403 from trezor.wire.errors import * # isort:skip # noqa: F401,F403
@ -187,6 +185,8 @@ async def protobuf_workflow(ctx, reader, handler, *args):
async def keychain_workflow(ctx, req, namespace, handler, *args): async def keychain_workflow(ctx, req, namespace, handler, *args):
from apps.common import seed
keychain = await seed.get_keychain(ctx, namespace) keychain = await seed.get_keychain(ctx, namespace)
args += (keychain,) args += (keychain,)
try: try: