Commit fd6c5dba authored by UNHALE NILESH ARUN's avatar UNHALE NILESH ARUN

minor fix

parent b5a476fc
lambda_proposer = 30# wait time for priority messages to be received
tou_proposer = 20 # proposer rolecount
tou_proposer = 26 # proposer rolecount
ROLE_BLOCK_PROPOSER = 'BLOCK_PROPOSER'
tou_step = 28 # tou is expected number of users that sortition selects for committee
tou_step = 60 # tou is expected number of users that sortition selects for committee
ROLE_COMMITEE_FOR_VOTE = 'committee'
lambda_block = 300 #seconds
......@@ -21,7 +21,7 @@ FINALIZED_BLOCK_msg_type = "FINALIZED_BLOCK"
TENTATIVE_BLOCK_msg_type = "TENTATIVE_BLOCK"
NUMBER_OF_NODES_IN_NETWORK = 30
NUMBER_OF_NODES_IN_NETWORK = 100
MAXSTEP = 15
FINAL_STEP = 9999999999
......
0 29
0 13
1 5
1 28
2 6
2 23
2 18
3 20
3 19
3 10
3 4
4 21
4 9
4 24
5 26
5 25
5 11
6 11
6 17
6 8
7 22
7 28
8 25
8 22
8 18
9 18
9 24
9 28
10 25
10 16
12 15
12 14
12 21
13 22
14 27
14 17
14 26
15 18
15 29
15 20
16 17
17 20
19 20
19 24
0 57
0 62
0 58
1 23
1 65
1 10
2 84
2 58
2 90
2 99
3 22
3 56
4 72
4 62
4 38
5 52
5 57
5 42
6 10
6 90
7 21
7 45
8 76
8 71
9 32
9 97
9 46
10 59
10 79
11 83
11 81
11 23
12 27
12 75
12 59
13 66
13 44
13 41
14 99
14 65
15 16
15 71
15 95
16 40
17 95
17 74
17 34
17 29
18 39
18 52
19 96
19 82
20 81
20 90
21 26
22 23
23 29
25 27
27 29
21 91
22 26
22 92
23 97
23 44
24 27
24 94
25 80
25 77
25 46
26 48
26 30
27 83
27 80
28 40
28 44
28 98
29 78
30 74
30 48
30 50
31 52
31 55
31 49
32 91
32 93
33 47
33 51
34 37
35 85
35 61
35 48
36 98
36 93
37 57
37 51
37 55
38 73
38 67
38 81
39 40
39 94
40 59
41 48
42 85
42 68
42 78
43 53
43 98
44 65
45 80
46 88
46 56
47 74
49 82
49 68
49 53
50 89
51 93
51 68
54 99
54 63
55 96
55 87
56 71
56 91
58 83
60 78
60 97
61 63
62 68
62 98
63 74
64 70
64 88
66 87
67 90
67 99
69 89
69 81
70 86
72 93
72 73
75 82
76 77
78 84
79 97
83 85
85 86
92 94
......@@ -19,6 +19,7 @@ class Network():
self.networkClockTime = 0
self.pk_weight_map = {}
self.time = 0
self.BlocksHashTOBLOCK_MAP = {}
def setupNetwork(self):
'''
......
......@@ -28,3 +28,73 @@
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
97
98
99
......@@ -29,7 +29,7 @@ class OverlayNode(Node):
self.currentRole = "BLOCK_PROPOSER"
self.currentSeed = None
self.currentPreviousHash = None
self.seenBlocksHashTOBLOCK_MAP = {}
self.startNodeLifeCycleGenerator = self.startNodeLifeCycle()
# adding initial task of bootstraping node.and it only contains ba* resume tasks
......@@ -225,6 +225,7 @@ class OverlayNode(Node):
self.logger.info("broadcsting BLOCK Proposal Message : {}".format(BLOCK_PROPOSAL_MSG_to_broadcast))
self.broadcast(self.network.time, BLOCK_PROPOSAL_MSG_to_broadcast)
blockForBA = (previousHash,BLOCK_PROPOSAL_MSG_to_broadcast[2])
self.network.BlocksHashTOBLOCK_MAP[Utility.pseudoRandomGenerator(blockForBA)] = blockForBA
self.logger.info('Proposed block : {}'.format(blockForBA))
else: # others than block proposers
......@@ -244,6 +245,7 @@ class OverlayNode(Node):
######### Performing selection of block BA* ############################
if not (self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type] or blockForBA) :
blockForBA = (previousHash,"Empty")
self.network.BlocksHashTOBLOCK_MAP[Utility.pseudoRandomGenerator(blockForBA)] = blockForBA
elif not blockForBA :
# Todo select block from highest priority node
blockForBA = (self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type][0][1],
......@@ -713,17 +715,18 @@ class OverlayNode(Node):
FNALIZED_BLOCK_msg = (
Config.FINALIZED_BLOCK_msg_type,hblockSTAR )
self.logger.info("FINALIZED BLOCK in round :"+str(self.currentRound)+" : {}".format(FNALIZED_BLOCK_msg))
self.blockchain.append(str((self.currentPreviousHash,hblockSTAR)))
self.blockchain.append(str(self.network.BlocksHashTOBLOCK_MAP[hblockSTAR]))
else:
TENTATIVE_BLOCK_msg = (Config.TENTATIVE_BLOCK_msg_type, hblockSTAR)
self.logger.info("TENTATIVE BLOCK in round :"+str(self.currentRound)+" : {}".format(TENTATIVE_BLOCK_msg))
self.tentativeblockchain.append(str((self.currentPreviousHash,hblockSTAR)))
self.tentativeblockchain.append(str(self.network.BlocksHashTOBLOCK_MAP[hblockSTAR]))
self.logger.info("BLOCKCHAIN : {}".format(self.blockchain))
self.printStats()
self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type].clear()
self.messagesTillNow.clear()
# self.messageQueue.clear()
self.logger.info("PROPOSED BLOCKS IN ROUND :"+str(self.currentRound)+" : {} ".format(self.network.BlocksHashTOBLOCK_MAP))
self.network.BlocksHashTOBLOCK_MAP.clear()
yield 'resume', 50
# self.logger.info(self.uniqueReceivedMessages)
......@@ -793,18 +796,19 @@ def takeSecond(elem):
if __name__ == '__main__':
d = {}
key = 2
value =5
d[key] = d.get(key, value)
##print(d[2])
v = 7
d[key] = d.get(key, v)
##print(d[2])
x = ['I am the first block', "('812a53b631914a36764fc9f8328dd019ce50f5c4b6051f670fbe0efb705efc77', 84736415767811103652304891014813354728426533548611541614918993721182826986444)", "('d31fbe19c2e713985ecdf394969c7790d19a87dcafa9c02cba0558bf12d544d4', 103122347745550455001943383981344366012988901432495847445355962900079905936198)", "('fd5a205348d15fc21b256ebd303a135857bda77a1993cf11303e45785aefb332', 47823573000215416532528435656381159431075140417141700821011381942532282748521)", "('9c868518b4d10e1a4a13046f6097f97d6df6dc1e95a661953d527a823ee6f050', 55460601694948737718196781018048019511931736228223657848800923874020053551928)", "('c2a3b56930d43645a93e865782abb0b4bac6681e693c9d50c13fd7391b4b7f25', 58707674458812810357241716928176455160340351916543706621213043845025913695452)", "('b03f15d0e7782a7f95fab6617411aa03f21cd9229e8e4f242ea4079ecd920cc2', 67573794190754323804116586417572734088575374646300010693539061879295897305162)", "('98d98b0732f5c5218a3b2ad49b5cba8c7d17c996ff4ea5689937684f2b20d79d', 69633357725200221165001650735647103204316958836713683487178046118094356870936)", "('9f4af3721891d947075907ba44c0d3587a6be51214b56be4478cbbfb54d5d88b', 66422139942822171704688570027380253905979677843036084427158008574677456200809)", "('86231ce45686fdafc82dc4159ba710e3f8b7fa31cf78dd25dcb8dfca313b4ac2', 108471944712883743347571235551646957426255157519283101098519720665762066857519)"]
y = ['I am the first block', "('812a53b631914a36764fc9f8328dd019ce50f5c4b6051f670fbe0efb705efc77', 84736415767811103652304891014813354728426533548611541614918993721182826986444)", "('d31fbe19c2e713985ecdf394969c7790d19a87dcafa9c02cba0558bf12d544d4', 103122347745550455001943383981344366012988901432495847445355962900079905936198)", "('fd5a205348d15fc21b256ebd303a135857bda77a1993cf11303e45785aefb332', 47823573000215416532528435656381159431075140417141700821011381942532282748521)", "('9c868518b4d10e1a4a13046f6097f97d6df6dc1e95a661953d527a823ee6f050', 55460601694948737718196781018048019511931736228223657848800923874020053551928)", "('c2a3b56930d43645a93e865782abb0b4bac6681e693c9d50c13fd7391b4b7f25', 58707674458812810357241716928176455160340351916543706621213043845025913695452)", "('b03f15d0e7782a7f95fab6617411aa03f21cd9229e8e4f242ea4079ecd920cc2', 67573794190754323804116586417572734088575374646300010693539061879295897305162)", "('98d98b0732f5c5218a3b2ad49b5cba8c7d17c996ff4ea5689937684f2b20d79d', 69633357725200221165001650735647103204316958836713683487178046118094356870936)", "('9f4af3721891d947075907ba44c0d3587a6be51214b56be4478cbbfb54d5d88b', 66422139942822171704688570027380253905979677843036084427158008574677456200809)", "('86231ce45686fdafc82dc4159ba710e3f8b7fa31cf78dd25dcb8dfca313b4ac2', 108471944712883743347571235551646957426255157519283101098519720665762066857519)"]
['I am the first block',
"('812a53b631914a36764fc9f8328dd019ce50f5c4b6051f670fbe0efb705efc77', 84736415767811103652304891014813354728426533548611541614918993721182826986444)",
"('d31fbe19c2e713985ecdf394969c7790d19a87dcafa9c02cba0558bf12d544d4', 103122347745550455001943383981344366012988901432495847445355962900079905936198)",
"('fd5a205348d15fc21b256ebd303a135857bda77a1993cf11303e45785aefb332', 47823573000215416532528435656381159431075140417141700821011381942532282748521)",
"('9c868518b4d10e1a4a13046f6097f97d6df6dc1e95a661953d527a823ee6f050', 55460601694948737718196781018048019511931736228223657848800923874020053551928)",
"('c2a3b56930d43645a93e865782abb0b4bac6681e693c9d50c13fd7391b4b7f25', 58707674458812810357241716928176455160340351916543706621213043845025913695452)",
"('b03f15d0e7782a7f95fab6617411aa03f21cd9229e8e4f242ea4079ecd920cc2', 67573794190754323804116586417572734088575374646300010693539061879295897305162)",
"('98d98b0732f5c5218a3b2ad49b5cba8c7d17c996ff4ea5689937684f2b20d79d', 69633357725200221165001650735647103204316958836713683487178046118094356870936)",
"('9f4af3721891d947075907ba44c0d3587a6be51214b56be4478cbbfb54d5d88b', 66422139942822171704688570027380253905979677843036084427158008574677456200809)",
"('86231ce45686fdafc82dc4159ba710e3f8b7fa31cf78dd25dcb8dfca313b4ac2', 108471944712883743347571235551646957426255157519283101098519720665762066857519)"]
print(len(x))
......
#!/usr/bin/env bash
#python3 filegen.py 30
python3 filegen.py 100
rm -rf ASim.log
......
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