2022-08-31 05:30:28 +00:00
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from enum import IntEnum, auto
|
|
|
|
import struct
|
|
|
|
|
|
|
|
import msgpack
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from onionrblocks import Block
|
|
|
|
|
2022-09-17 05:02:49 +00:00
|
|
|
from wot.exceptions import InvalidWotBlock
|
2022-08-31 05:30:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
class WotCommand(IntEnum):
|
|
|
|
TRUST = 1
|
2022-09-15 06:27:46 +00:00
|
|
|
REVOKE_TRUST = auto()
|
2022-08-31 05:30:28 +00:00
|
|
|
ANNOUNCE = auto()
|
|
|
|
REVOKE = auto()
|
|
|
|
|
2022-09-08 23:44:23 +00:00
|
|
|
|
2022-08-31 05:30:28 +00:00
|
|
|
class WotPayload:
|
|
|
|
def __init__(self, block_data: bytes):
|
|
|
|
wot_command = WotCommand(
|
|
|
|
int.from_bytes(block_data[0], byteorder='big'))
|
|
|
|
|
|
|
|
|
|
|
|
match wot_command(WotCommand):
|
|
|
|
case WotCommand.TRUST:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def process_block(bl: 'Block'):
|
|
|
|
assert bl.type == 'iden'
|
|
|
|
wot_command = WotCommand(bl.data)
|