aboutsummaryrefslogtreecommitdiff
path: root/src/consensus/consensus-simulation.py.in
diff options
context:
space:
mode:
Diffstat (limited to 'src/consensus/consensus-simulation.py.in')
-rw-r--r--src/consensus/consensus-simulation.py.in13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/consensus/consensus-simulation.py.in b/src/consensus/consensus-simulation.py.in
index 161015d00..39daf81c6 100644
--- a/src/consensus/consensus-simulation.py.in
+++ b/src/consensus/consensus-simulation.py.in
@@ -17,16 +17,9 @@
17# 17#
18# SPDX-License-Identifier: AGPL3.0-or-later 18# SPDX-License-Identifier: AGPL3.0-or-later
19 19
20from __future__ import absolute_import
21from __future__ import print_function
22from __future__ import division
23from builtins import str
24from builtins import range
25from past.utils import old_div
26import argparse 20import argparse
27import random 21import random
28from math import ceil, log, floor 22from math import ceil, log, floor
29from past.builtins import xrange
30 23
31 24
32def bsc(n): 25def bsc(n):
@@ -43,14 +36,12 @@ def bsc(n):
43 36
44def simulate(k, n, verbose): 37def simulate(k, n, verbose):
45 assert k < n 38 assert k < n
46 largest_arc = old_div(int(2**ceil(log(n, 2))), 2) 39 largest_arc = int(2**ceil(log(n, 2))) // 2
47 num_ghosts = (2 * largest_arc) - n 40 num_ghosts = (2 * largest_arc) - n
48 if verbose: 41 if verbose:
49 print("we have", num_ghosts, "ghost peers") 42 print("we have", num_ghosts, "ghost peers")
50 # n.b. all peers with idx<k are evil 43 # n.b. all peers with idx<k are evil
51 peers = list(range(n)) 44 peers = list(range(n))
52 # py2-3 compatible, backwards.
53 # refer to http://python-future.org/compatible_idioms.html#xrange
54 info = [1 << x for x in range(n)] 45 info = [1 << x for x in range(n)]
55 46
56 def done_p(): 47 def done_p():
@@ -111,4 +102,4 @@ if __name__ == "__main__":
111 sum = 0.0 102 sum = 0.0
112 for n in range(0, args.r): 103 for n in range(0, args.r):
113 sum += simulate(args.k, args.n, args.verbose) 104 sum += simulate(args.k, args.n, args.verbose)
114 print(old_div(sum, args.r)) 105 print(sum // args.r)