experiments on generating timeout events using yield and todolist

parent c1a31701
......@@ -70,7 +70,7 @@ def sortition(sk,seed,rolecount,role,w,badaW,pk):
# print(x)
lastValue = 0;
lastValue = 0
# print("probability : ",p)
......@@ -79,7 +79,7 @@ def sortition(sk,seed,rolecount,role,w,badaW,pk):
lastValue = lastValue + stats.binom.pmf(j, w, p)
nextvalue = lastValue + stats.binom.pmf(j + 1, w, p)
# print(lastValue,nextvalue)
if (((lastValue<=x) and (nextvalue>x))):
if (((lastValue<=x) and (x<nextvalue))):
break
if j == w+1:
j=0
......@@ -230,22 +230,8 @@ def testVerifyVRF():
status = verifyVRF(pk,hash,proof,seed2)
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__':
# testSortition()
# testVerifyVRF()
# testVerifySort()
m = generator()
for i n
testVerifySort()
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