src/trezor/wire: allow passing MessageType classes to register()

pull/25/head
Jan Pochyla 6 years ago
parent 2731742d34
commit 60bec0b4d1

@ -13,6 +13,8 @@ workflow_handlers = {}
def register(mtype, handler, *args):
'''Register `handler` to get scheduled after `mtype` message is received.'''
if isinstance(mtype, type) and issubclass(mtype, protobuf.MessageType):
mtype = mtype.MESSAGE_WIRE_TYPE
if mtype in workflow_handlers:
raise KeyError
workflow_handlers[mtype] = (handler, args)

Loading…
Cancel
Save