Created
May 2, 2021 16:04
-
-
Save samueleresca/d1c5e7bcffc42769e0e48c40ecb4825a 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
""" | |
Original code available at: https://github.com/mwhittaker/quoracle/blob/master/quoracle/quorum_system.py#L622 | |
""" | |
class Strategy(Generic[T]): | |
# ... | |
def quorum_system(self) -> QuorumSystem[T]: | |
return self.qs | |
def node(self, x: T) -> Node[T]: | |
return self.qs.node(x) | |
def nodes(self) -> Set[Node[T]]: | |
return self.qs.nodes() | |
def get_read_quorum(self) -> Set[T]: | |
return set(random.choices(list(self.sigma_r.keys()), | |
weights=list(self.sigma_r.values()))[0]) | |
def get_write_quorum(self) -> Set[T]: | |
return set(random.choices(list(self.sigma_w.keys()), | |
weights=list(self.sigma_w.values()))[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment