"""ClientMessage — container for client-originated messages. Ported from net.i2p.data.i2cp.ClientMessage. Used by the message routing system to track outbound messages. """ from __future__ import annotations import hashlib from dataclasses import dataclass class SendFlags: """Send flags for outbound messages.""" NONE = 0 TAG_THRESHOLD_LOW = 1 TAG_THRESHOLD_HIGH = 2 @dataclass class ClientMessage: """A client-originated message with routing metadata.""" from_dest: bytes to_dest: bytes payload: bytes message_id: int message_nonce: int expiration: int | None = None flags: int = 0 @property def from_hash(self) -> bytes: """SHA-256 hash of the source destination.""" return hashlib.sha256(self.from_dest).digest() @property def to_hash(self) -> bytes: """SHA-256 hash of the target destination.""" return hashlib.sha256(self.to_dest).digest() @property def payload_size(self) -> int: return len(self.payload)