Created
September 26, 2015 20:33
-
-
Save rystsov/23ff19e75903f6d87b39 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 Variable: | |
def __init__(self, nodes, q, node_id): | |
self.proposer = Proposer(nodes, q, node_id) | |
@endpoint | |
def write(self, ver, value, due): | |
def change(previous): | |
if previous == None or previous.ver==ver: | |
return Val(ver = ver+1, value = value) | |
return previous | |
def query(current): | |
if current.ver == ver+1 and current.value==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