Skip to content

Instantly share code, notes, and snippets.

@amirziai
Created September 25, 2022 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amirziai/69ec23ca8ef8103e9b22d01bb19e3fc2 to your computer and use it in GitHub Desktop.
Save amirziai/69ec23ca8ef8103e9b22d01bb19e3fc2 to your computer and use it in GitHub Desktop.
@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