Skip to content

Instantly share code, notes, and snippets.

@samueleresca
Created May 2, 2021 16:04
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 samueleresca/d1c5e7bcffc42769e0e48c40ecb4825a to your computer and use it in GitHub Desktop.
Save samueleresca/d1c5e7bcffc42769e0e48c40ecb4825a to your computer and use it in GitHub Desktop.
"""
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