Skip to content

Instantly share code, notes, and snippets.

@rystsov
Last active September 27, 2015 06:11
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 rystsov/0f5f6bcb82b9d666769d to your computer and use it in GitHub Desktop.
Save rystsov/0f5f6bcb82b9d666769d to your computer and use it in GitHub Desktop.
class Switch:
def __init__(self, nodes, q, node_id):
self.proposer = Proposer(nodes, q, node_id)
@endpoint
def write(self, value, due):
def change(previous):
return value if previous == None else previous
def query(current):
if current == value:
return current
raise Conflict(current)
return self.proposer.change_query(change, query, due)
@endpoint
def read(self, due):
def change(previous):
return previous
def query(current):
return current
return self.proposer.change_query(change, query, due)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment