Last active
September 27, 2015 06:11
-
-
Save rystsov/0f5f6bcb82b9d666769d 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
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