|
23 | 23 | import itertools
|
24 | 24 | import random
|
25 | 25 | from collections import deque
|
26 |
| -from dataclasses import dataclass |
27 | 26 | from typing import (
|
28 | 27 | TYPE_CHECKING,
|
29 | 28 | Dict,
|
|
75 | 74 | _RESPOND_IMMEDIATE_TYPES = {_TYPE_NSEC, _TYPE_SRV, *_ADDRESS_RECORD_TYPES}
|
76 | 75 |
|
77 | 76 |
|
78 |
| -@dataclass |
79 | 77 | class QuestionAnswers:
|
80 |
| - ucast: _AnswerWithAdditionalsType |
81 |
| - mcast_now: _AnswerWithAdditionalsType |
82 |
| - mcast_aggregate: _AnswerWithAdditionalsType |
83 |
| - mcast_aggregate_last_second: _AnswerWithAdditionalsType |
| 78 | + """A group of answers for a question.""" |
| 79 | + |
| 80 | + __slots__ = ("ucast", "mcast_now", "mcast_aggregate", "mcast_aggregate_last_second") |
| 81 | + |
| 82 | + def __init__( |
| 83 | + self, |
| 84 | + ucast: _AnswerWithAdditionalsType, |
| 85 | + mcast_now: _AnswerWithAdditionalsType, |
| 86 | + mcast_aggregate: _AnswerWithAdditionalsType, |
| 87 | + mcast_aggregate_last_second: _AnswerWithAdditionalsType, |
| 88 | + ) -> None: |
| 89 | + """Initialize the question answers.""" |
| 90 | + self.ucast = ucast |
| 91 | + self.mcast_now = mcast_now |
| 92 | + self.mcast_aggregate = mcast_aggregate |
| 93 | + self.mcast_aggregate_last_second = mcast_aggregate_last_second |
84 | 94 |
|
85 | 95 |
|
86 |
| -@dataclass |
87 | 96 | class AnswerGroup:
|
88 | 97 | """A group of answers scheduled to be sent at the same time."""
|
89 | 98 |
|
90 |
| - send_after: float # Must be sent after this time |
91 |
| - send_before: float # Must be sent before this time |
92 |
| - answers: _AnswerWithAdditionalsType |
| 99 | + __slots__ = ("send_after", "send_before", "answers") |
| 100 | + |
| 101 | + def __init__(self, send_after: float, send_before: float, answers: _AnswerWithAdditionalsType) -> None: |
| 102 | + """Initialize the answer group.""" |
| 103 | + self.send_after = send_after # Must be sent after this time |
| 104 | + self.send_before = send_before # Must be sent before this time |
| 105 | + self.answers = answers |
93 | 106 |
|
94 | 107 |
|
95 | 108 | def _message_is_probe(msg: DNSIncoming) -> bool:
|
|
0 commit comments