-
Notifications
You must be signed in to change notification settings - Fork 0
/
Type.py
54 lines (41 loc) · 1.2 KB
/
Type.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class Prepare:
def __init__(self, ballot):
self.ballot = ballot
class Promise:
def __init__(self, ballot, acceptNum, acceptVal):
self.ballot = ballot
self.acceptNum = acceptNum
self.acceptVal = acceptVal
class Accept:
def __init__(self, b, v):
self.b = b
self.v = v
class Accepted:
def __init__(self, b, v,you):
self.b = b
self.v = v
self.you =you
class Decision:
def __init__(self, v):
self.v = v
class Ballot:
def __init__(self, num, process_id, depth):
self.num = num
self.process_id = process_id
self.depth = depth
def increment_num(self):
self.num = self.num + 1
def __ge__(self, other):
if self.num > other.num:
return True
elif self.num == other.num and self.process_id >= other.process_id:
return True
else:
return False
def __le__(self, other):
if self.num < other.num:
return True
elif self.num == other.num and self.process_id <= other.process_id:
return True
else:
return False