blob: d7bfc7e21957f2797bd038ddd7f5a52778b1d81a (
plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
"""
priest ledger format
-------------------
front #denotes the start of the actual ledger
0/1,n,0/1 #voted or not, ballot number, promised or not
promised or not explanation: whether or not this priest has promised to not
respond to maxvote requests after this ballot
"""
"""
paxons are very religious; god controls anything and everything and the synod ritual
lies in that domain (of anything and everything, that is)
- literally creates leaders and priests ie initializes the objects
- assigns ballot number ranges for each priest (so B1 is satisfied)
"""
class god:
"""
messenger relays messages to and from the leader and the priest
she accomplishes this by tracking the priests' ledger files for changes
each priest (including the leader) has a personal messenger
"""
class messenger(god):
"""
leader messenger functions
"""
def send_next_ballot():
def send_begin_ballot():
def send_on_success():
"""
priest messenger functions
"""
def send_last_vote():
def send_vote():
"""
priests are present (or not present) and vote (or not vote) for ballots proposed
by the leader
they record all ballots they have participated in in individual ledger files
"""
class priest(god, messenger):
def __init__(self, name, is_leader):
self.name = name #write this name in the ledger in case it gets lost (ledger fileaname)
self.is_leader = is_leader
self.messenger = messenger(); #hire a messenger
if(self.is_leader):
#====================regular priest functions======================
def last_vote():
#responding to a next_ballot request from the leader
#determine the lastVote and send it to the leader (if not promised to another leader) (might
#need another function for this)
#if responded, set promise to 1 for the relevant maxVote in the ledger
def vote():
#choose (randomly) whether or not to vote on this ballot
#send the vote to the leader (another function "voted"?)
def on_success():
#do something if the messenger brings the good news of a ballot success
#=====================leader functions===================
def next_ballot(ballot_num):
#randomly choose a majority set of priests
#send the nextBallot message to the priests and wait for their responses
def begin_ballot():
#send message to every priest indicating that his vote is requested
def evaluate():
#check if the ballot was a success and note the decree if it was
#send the sucess message to all living priests
|