aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAditya Naik2017-12-01 17:39:34 -0500
committerAditya Naik2017-12-01 17:39:34 -0500
commitad1b2ceccc0d1b1e178d3abb0876be9e521ab459 (patch)
treebf63a978120e117237de2fed256e2dfce515e22c
parent207e51adfcda31fcf91f567af2f10f055340d3d9 (diff)
code skeleton v3
-rw-r--r--prelim.py33
1 files changed, 26 insertions, 7 deletions
diff --git a/prelim.py b/prelim.py
index d7bfc7e..6a4b825 100644
--- a/prelim.py
+++ b/prelim.py
@@ -2,9 +2,10 @@
priest ledger format
-------------------
front #denotes the start of the actual ledger
-0/1,n,0/1 #voted or not, ballot number, promised or not
+0/1,n,0/1,x #voted or not, ballot number, promised or not, adder multiplier
promised or not explanation: whether or not this priest has promised to not
respond to maxvote requests after this ballot
+adder multiplier explanation: (see doc for messenger)
"""
@@ -15,7 +16,7 @@ lies in that domain (of anything and everything, that is)
- assigns ballot number ranges for each priest (so B1 is satisfied)
"""
class god:
-
+ pass
"""
messenger relays messages to and from the leader and the priest
@@ -23,23 +24,29 @@ she accomplishes this by tracking the priests' ledger files for changes
each priest (including the leader) has a personal messenger
"""
-class messenger(god):
+
+class messenger():
"""
leader messenger functions
"""
def send_next_ballot():
+ pass
def send_begin_ballot():
-
+ pass
+
def send_on_success():
+ pass
"""
priest messenger functions
"""
def send_last_vote():
+ pass
def send_vote():
+ pass
@@ -47,21 +54,28 @@ class messenger(god):
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
+
+note: unique sets of numbers are created by an 'adder': starting from a base value,
+each priest determines next ballot number by adding adder*x where x is the number of
+ballots he's assigned numbers before the current ballot
"""
class priest(god, messenger):
- def __init__(self, name, is_leader):
+ def __init__(self, name, is_leader, adder):
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
+ self.messenger = messenger() #hire a messenger
+ self.adder = adder
+ self.ledger = open("ledgers/" + self.name, "+")
- if(self.is_leader):
+ #if(self.is_leader):
#====================regular priest functions======================
def last_vote():
+ pass
#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)
@@ -69,23 +83,28 @@ class priest(god, messenger):
#if responded, set promise to 1 for the relevant maxVote in the ledger
def vote():
+ pass
#choose (randomly) whether or not to vote on this ballot
#send the vote to the leader (another function "voted"?)
def on_success():
+ pass
#do something if the messenger brings the good news of a ballot success
#=====================leader functions===================
def next_ballot(ballot_num):
+ pass
#randomly choose a majority set of priests
#send the nextBallot message to the priests and wait for their responses
def begin_ballot():
+ pass
#send message to every priest indicating that his vote is requested
def evaluate():
+ pass
#check if the ballot was a success and note the decree if it was
#send the sucess message to all living priests