"""What a question put to every server came back with (B-78). `active` is the answer of the connection the platform is running on, `others` those of each other configured server in configuration order; `None` stands for "no usable answer" (unreachable, timed out, an error that is not an answer).""" from typing import NamedTuple class ServerAnswers(NamedTuple): active: object | None others: tuple others_needed: int # how many of `others` must have answered for the network to count @property def answered_others(self) -> list: return [answer for answer in self.others if answer is not None] @property def complete(self) -> bool: """Enough of the network answered for its silence to mean something: the active server and at least `others_needed` of the others.""" return self.active is not None and len(self.answered_others) >= self.others_needed @property def all(self) -> list: return ([] if self.active is None else [self.active]) + self.answered_others