Created
September 25, 2022 22:49
-
-
Save amirziai/69ec23ca8ef8103e9b22d01bb19e3fc2 to your computer and use it in GitHub Desktop.
This file contains 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 characters
@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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment