Created
September 25, 2022 22:49
Revisions
-
amirziai created this gist
Sep 25, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ @dataclass(frozen=True) class ServerToken: server_id: ServerId token_idx: int _seed: int = SEED @property @functools.lru_cache() def key(self) -> str: return f"{self.node_id}-{self.token_idx}" @property @functools.lru_cache() def hash_value(self) -> int: return hash_mmh3(key=self.key, seed=self._seed) def __lt__(self, other: "Node") -> bool: return self.hash_value < other.hash_value