More efficently(?) check quorum system validity.
This commit is contained in:
parent
7f1a1a3934
commit
68a939b3e6
1 changed files with 6 additions and 4 deletions
|
@ -18,10 +18,12 @@ class QuorumSystem(Generic[T]):
|
|||
def __init__(self, reads: Optional[Expr[T]] = None,
|
||||
writes: Optional[Expr[T]] = None) -> None:
|
||||
if reads is not None and writes is not None:
|
||||
# TODO(mwhittaker): Think of ways to make this more efficient.
|
||||
assert all(len(r & w) > 0
|
||||
for (r, w) in itertools.product(reads.quorums(),
|
||||
writes.quorums()))
|
||||
optimal_writes = reads.dual()
|
||||
if not all(optimal_writes.is_quorum(write_quorum)
|
||||
for write_quorum in writes.quorums()):
|
||||
raise ValueError(
|
||||
'Not all read quorums intersect all write quorums')
|
||||
|
||||
self.reads = reads
|
||||
self.writes = writes
|
||||
elif reads is not None and writes is None:
|
||||
|
|
Loading…
Reference in a new issue