experiments on generating timeout events using yield and todolist

parent c1a31701
...@@ -70,7 +70,7 @@ def sortition(sk,seed,rolecount,role,w,badaW,pk): ...@@ -70,7 +70,7 @@ def sortition(sk,seed,rolecount,role,w,badaW,pk):
# print(x) # print(x)
lastValue = 0; lastValue = 0
# print("probability : ",p) # print("probability : ",p)
...@@ -79,7 +79,7 @@ def sortition(sk,seed,rolecount,role,w,badaW,pk): ...@@ -79,7 +79,7 @@ def sortition(sk,seed,rolecount,role,w,badaW,pk):
lastValue = lastValue + stats.binom.pmf(j, w, p) lastValue = lastValue + stats.binom.pmf(j, w, p)
nextvalue = lastValue + stats.binom.pmf(j + 1, w, p) nextvalue = lastValue + stats.binom.pmf(j + 1, w, p)
# print(lastValue,nextvalue) # print(lastValue,nextvalue)
if (((lastValue<=x) and (nextvalue>x))): if (((lastValue<=x) and (x<nextvalue))):
break break
if j == w+1: if j == w+1:
j=0 j=0
...@@ -230,22 +230,8 @@ def testVerifyVRF(): ...@@ -230,22 +230,8 @@ def testVerifyVRF():
status = verifyVRF(pk,hash,proof,seed2) status = verifyVRF(pk,hash,proof,seed2)
print(status) print(status)
class generator:
def __init__(self):
self.todoList = [self.gen]
def gen(self):
x=0
while True:
x+=1
self.todoList.insert(0,self.gen)
yield x
if __name__ == '__main__': if __name__ == '__main__':
# testSortition() # testSortition()
# testVerifyVRF() # testVerifyVRF()
# testVerifySort() testVerifySort()
m = generator()
for i n
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment