mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-08-24 10:05:29 -05:00
* Enable PEP604 Ruff rules * Fix harcoded signature in test * Hack CLVMStreamable test with note to fast follow
36 lines
814 B
Python
36 lines
814 B
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from enum import IntEnum
|
|
from typing import SupportsBytes
|
|
|
|
from chia_rs.sized_ints import uint8, uint16
|
|
|
|
from chia.protocols.protocol_message_types import ProtocolMessageTypes
|
|
from chia.util.streamable import Streamable, streamable
|
|
|
|
|
|
class NodeType(IntEnum):
|
|
FULL_NODE = 1
|
|
HARVESTER = 2
|
|
FARMER = 3
|
|
TIMELORD = 4
|
|
INTRODUCER = 5
|
|
WALLET = 6
|
|
DATA_LAYER = 7
|
|
SOLVER = 8
|
|
|
|
|
|
@streamable
|
|
@dataclass(frozen=True)
|
|
class Message(Streamable):
|
|
type: uint8 # one of ProtocolMessageTypes
|
|
# message id
|
|
id: uint16 | None
|
|
# Message data for that type
|
|
data: bytes
|
|
|
|
|
|
def make_msg(msg_type: ProtocolMessageTypes, data: bytes | SupportsBytes) -> Message:
|
|
return Message(uint8(msg_type.value), None, bytes(data))
|