Skip to content

Commit

Permalink
Added symolic names
Browse files Browse the repository at this point in the history
  • Loading branch information
gdanezis committed Nov 11, 2017
1 parent 0958505 commit 07f4e74
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pybft/replica.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class replica(object):

_PREPREPARE = 1000
_PREPARE = 1001
_REPLY = 1002
_REQUEST = 1003
_COMMIT = 1004

def __init__(self,i, R):
self.i = i
Expand Down Expand Up @@ -78,7 +81,7 @@ def commited(self, m, v, n, M=None):

others = set()
for mx in M:
if mx[:4] == ("COMMIT", v, n, self.hash(m)):
if mx[:4] == (self._COMMIT, v, n, self.hash(m)):
if mx[4] != self.primary():
others.add(mx[4])

Expand All @@ -93,7 +96,7 @@ def receive_request(self, msg):

# We have already replied to the message
if t == self.last_rep_i[c]:
new_reply = ("REPLY", self.view_i, t, c, self.i, last_rep_i[c])
new_reply = (self._REPLY, self.view_i, t, c, self.i, last_rep_i[c])
self.out_i.add( new_reply )
else:
self.in_i.add( msg )
Expand Down Expand Up @@ -150,7 +153,7 @@ def send_preprepare(self, m, v, n):
cond &= m in self.in_i

# Ensure we only process once.
cond &= m[0] == "REQUEST"
cond &= m[0] == self._REQUEST
for ms in self.in_i:
if ms[0] == self._PREPREPARE:
(_, vp, np, mp, ip) = ms
Expand All @@ -163,7 +166,7 @@ def send_preprepare(self, m, v, n):
self.in_i.add(p)

def send_commit(self, m, v, n):
c = ("COMMIT", v, n, self.hash(m), self.i)
c = (self._COMMIT, v, n, self.hash(m), self.i)
if self.prepared(m,v,n) and c not in self.in_i:
self.out_i.add(c)
self.in_i.add(c)
Expand All @@ -177,7 +180,7 @@ def execute(self, m, v, n):
if t > self.last_rep_ti[c]:
self.last_rep_ti[c] = t
self.last_rep_i[c], self.vali = None, None # EXEC
rep = ("REPLY", self.view_i, t, c, self.i, self.last_rep_i[c])
rep = (self._REPLY, self.view_i, t, c, self.i, self.last_rep_i[c])
self.out_i.add(rep)
self.in_i.remove(m)

0 comments on commit 07f4e74

Please sign in to comment.