Commit 41e9287d authored by THAKARE AKSHAY HARIBHAU's avatar THAKARE AKSHAY HARIBHAU

Merge branch 'algorand' into 'Nalgo'

# Conflicts:
#   filegen.py
parents e2ab3569 6113f258
lambda_proposer = 3 # wait time for priority messages to be received
tou_proposer = 20 # proposer rolecount
ROLE_BLOCK_PROPOSER = 'BLOCK_PROPOSER'
tou_step = 3 # tou is expected number of users that sortition selects for committee
ROLE_COMMITEE_FOR_VOTE = 'committee'
lambda_block = 30 #seconds
lambda_step = 3
BLOCK_PROPOSAL_MSG_type = 'BLOCK_PROPOSAL_MSGs'
PRIORITY_MSG_type = 'PRIORITY_MSG'
COMMITTEE_VOTE_MSG_type = "COMMITTEE_VOTE"
TIMEOUT = "TIMEOUT"
T = 2/3 # T isa a fraction of expected committee size that defines BA*`s voting thershold
...@@ -2,3 +2,7 @@ ...@@ -2,3 +2,7 @@
2 3 2 3
3 4 3 4
4 1 4 1
3 5
2 6
3 7
7 4
\ No newline at end of file
0 10 0 20
0 27 0 34
0 35 0 35
0 38 0 42
0 46 0 48
0 50 1 7
0 61 1 18
0 63 1 23
0 73 1 34
0 80
0 82
0 88
0 97
0 109
0 110
0 120
0 121
0 125
0 128
0 130
0 144
0 162
0 164
0 195
1 5
1 8
1 12
1 19
1 24
1 33
1 38
1 40
1 43
1 47
1 56
1 57
1 64
1 75
1 102
1 166
2 7
2 15 2 15
2 18 2 26
2 20 3 7
2 23 3 18
2 29 3 27
2 38 3 29
2 39 3 34
2 43
2 56
2 58
2 63
2 72
2 78
2 85
2 87
2 106
2 108
2 115
2 117
2 123
2 130
2 135
2 137
2 153
2 157
2 159
2 160
2 170
2 192
2 195
2 198
3 21
3 23
3 31
3 41 3 41
3 87 3 46
3 97 4 9
3 101
3 106
3 109
3 113
3 118
3 140
3 145
3 152
3 157
3 162
3 181
3 182
3 190
3 193
3 197
3 199
4 10
4 15
4 17 4 17
4 23 4 25
4 26 4 38
4 60 4 45
4 82 4 49
4 84 5 21
4 86 5 30
4 88 5 34
4 91
4 93
4 102
4 112
4 123
4 128
4 134
4 149
4 151
4 153
4 172
4 178
4 183
4 187
4 190
4 196
5 9
5 28
5 42
5 47 5 47
5 59 6 7
5 65 6 9
5 73 6 47
5 127 7 16
5 135 7 19
5 146 8 14
5 149 8 22
5 151
5 162
5 164
5 166
5 177
5 178
5 187
5 191
6 12
6 17
6 25
6 44
6 45
6 50
6 64
6 69
6 81
6 94
6 99
6 130
6 132
6 142
6 154
6 171
6 174
6 186
7 11
7 18
7 26
7 30
7 42
7 61
7 73
7 88
7 90
7 94
7 125
7 129
7 131
7 144
7 169
7 197
8 17
8 25 8 25
8 36 9 16
8 37 9 31
8 40 9 41
8 42 9 44
8 50 10 36
8 51 10 39
8 66
8 95
8 100
8 118
8 126
8 139
8 152
8 155
8 163
8 197
9 24
9 25
9 42
9 54
9 56
9 63
9 68
9 77
9 83
9 102
9 108
9 124
9 128
9 133
9 139
9 140
9 150
9 195
10 18
10 38
10 43
10 52
10 68
10 76
10 92
10 95
10 106
10 140
10 154
10 158
10 166
10 167
10 172
10 176
10 177
10 180
10 195
10 197
11 13 11 13
11 25 11 17
11 35 11 34
11 39 11 39
11 41 11 43
11 51 12 15
11 59
11 60
11 66
11 67
11 68
11 82
11 84
11 94
11 116
11 118
11 121
11 161
11 162
11 167
12 17 12 17
12 20 12 21
12 39 12 30
12 61 12 35
12 75
12 85
12 112
12 115
12 122
12 130
12 141
12 152
12 161
12 162
12 173
12 194
13 14 13 14
13 29 13 15
13 50 14 17
13 63 14 24
13 70 14 36
13 80 14 48
13 103 15 19
13 118 15 26
13 125 15 32
13 127 15 37
13 131 15 38
13 137 15 40
13 141 16 25
13 163
13 174
14 15
14 26
14 31
14 42
14 56
14 77
14 81
14 83
14 96
14 98
14 99
14 104
14 108
14 113
14 115
14 130
14 132
14 146
14 161
14 163
14 178
14 184
14 188
15 16
15 28
15 56
15 61
15 63
15 94
15 96
15 102
15 108
15 112
15 113
15 136
15 158
15 170
15 185
16 19
16 29
16 36 16 36
16 55 16 46
16 64
16 65
16 75
16 85
16 88
16 93
16 97
16 106
16 112
16 113
16 119
16 124
16 151
16 160
16 165
16 175
16 193
17 25 17 25
17 42 17 29
17 48 17 47
17 82 18 25
17 90 18 47
17 109 19 23
17 118 19 24
17 123 19 33
17 157 19 37
17 169 20 21
17 191 20 28
17 195
18 28
18 37
18 44
18 45
18 53
18 60
18 68
18 77
18 92
18 109
18 114
18 129
18 134
18 137
18 149
18 168
18 174
18 189
18 190
18 193
19 32
19 43
19 51
19 68
19 75
19 79
19 81
19 87
19 90
19 100
19 111
19 124
19 125
19 131
19 134
19 140
19 152
19 158
19 164
19 169
19 174
19 189
19 193
19 195
20 32 20 32
20 47 20 36
20 50 20 44
20 68 20 48
20 69 23 27
20 86 23 39
20 94 23 40
20 97 25 32
20 124 25 40
20 127 25 42
20 134 25 49
20 136 27 43
20 143 27 47
20 152
20 155
20 156
20 159
20 166
20 173
20 177
20 187
21 29
21 36
21 41
21 51
21 85
21 86
21 133
21 141
21 175
21 183
21 189
22 25
22 27
22 43
22 53
22 59
22 75
22 89
22 96
22 120
22 122
22 127
22 147
22 151
22 153
23 47
23 102
23 112
23 126
23 129
23 139
23 141
23 149
23 162
23 171
23 188
23 192
23 194
23 197
24 28
24 37
24 55
24 57
24 61
24 74
24 79
24 86
24 100
24 108
24 113
24 126
24 127
24 131
24 133
24 135
24 139
24 190
25 41
25 61
25 72
25 82
25 83
25 87
25 93
25 102
25 104
25 111
25 120
25 126
25 127
25 132
25 150
25 194
25 196
26 32
26 37
26 39
26 63
26 66
26 67
26 85
26 109
26 114
26 115
26 116
26 141
26 143
26 157
26 177
26 180
26 185
26 187
26 188
26 192
27 29
27 42
27 60
27 66
27 68
27 97
27 98
27 111
27 119
27 126
27 142
27 151
27 158
27 162
27 170
27 175
27 191
27 193
28 33 28 33
28 35
28 43 28 43
28 60 29 44
28 74 30 47
28 81 30 48
28 83 31 35
28 99 31 41
28 100 32 34
28 103 32 38
28 105 32 40
28 113 32 41
28 114 32 43
28 182 33 44
28 185 34 37
29 65 34 41
29 71 34 46
29 81 37 39
29 85 41 46
29 89 41 47
29 97 41 49
29 122 43 46
29 128 43 47
29 137 44 48
29 144 47 48
29 146
29 164
29 195
30 52
30 53
30 59
30 68
30 71
30 87
30 89
30 91
30 103
30 133
30 159
30 165
30 182
30 184
30 188
31 34
31 39
31 49
31 65
31 84
31 87
31 88
31 94
31 112
31 154
31 167
31 191
32 42
32 45
32 47
32 56
32 58
32 62
32 71
32 87
32 88
32 92
32 101
32 103
32 117
32 120
32 134
32 145
32 149
32 154
32 162
32 163
32 172
32 175
32 177
33 38
33 58
33 60
33 79
33 83
33 88
33 96
33 105
33 112
33 136
33 149
33 168
33 169
33 176
33 182
33 183
33 189
33 190
34 36
34 54
34 130
34 146
34 153
34 158
34 159
34 165
34 169
34 180
34 184
35 59
35 90
35 111
35 123
35 128
35 137
35 140
35 152
35 189
35 191
35 193
36 42
36 60
36 63
36 74
36 78
36 98
36 103
36 109
36 115
36 122
36 125
36 161
36 168
36 184
36 186
36 190
36 191
36 194
36 195
36 199
37 42
37 61
37 95
37 103
37 104
37 112
37 126
37 130
37 131
37 143
37 162
37 167
37 194
38 44
38 58
38 61
38 62
38 67
38 69
38 82
38 116
38 120
38 124
38 135
38 174
38 176
38 181
38 186
39 42
39 52
39 59
39 78
39 84
39 104
39 112
39 115
39 118
39 130
39 134
39 148
39 166
39 172
39 193
39 197
39 199
40 58
40 69
40 88
40 92
40 109
40 132
40 150
40 170
40 173
40 181
41 43
41 60
41 61
41 65
41 73
41 78
41 92
41 100
41 101
41 116
41 117
41 121
41 126
41 128
41 132
41 135
41 162
41 199
42 56
42 61
42 67
42 83
42 86
42 91
42 99
42 111
42 172
42 189
42 194
43 77
43 88
43 109
43 120
43 163
43 188
43 193
43 195
44 46
44 47
44 62
44 68
44 69
44 84
44 97
44 102
44 105
44 120
44 122
44 125
44 128
44 139
44 153
44 155
44 160
44 178
44 197
45 54
45 60
45 63
45 68
45 77
45 79
45 106
45 144
45 153
45 161
45 175
45 176
46 48
46 75
46 77
46 81
46 85
46 89
46 93
46 114
46 118
46 120
46 133
46 168
46 187
46 199
47 54
47 81
47 95
47 107
47 108
47 110
47 114
47 138
47 139
47 148
47 151
47 165
47 172
47 176
47 195
47 197
48 50
48 58
48 59
48 60
48 72
48 80
48 81
48 96
48 99
48 100
48 119
48 159
48 178
48 179
48 194
49 55
49 81
49 83
49 93
49 98
49 120
49 125
49 131
49 156
49 157
49 185
49 192
49 195
49 196
50 57
50 64
50 88
50 100
50 102
50 106
50 113
50 122
50 152
50 166
50 176
50 178
50 179
51 60
51 85
51 101
51 110
51 116
51 135
51 139
51 143
51 147
51 151
51 153
51 167
51 171
51 174
51 177
51 186
52 53
52 56
52 59
52 79
52 82
52 90
52 99
52 105
52 107
52 109
52 112
52 126
52 137
52 143
52 145
52 146
52 156
52 181
52 189
52 190
52 197
52 198
53 55
53 92
53 104
53 107
53 126
53 138
53 145
53 153
53 159
53 162
53 175
53 186
53 192
54 60
54 61
54 65
54 141
54 145
54 149
54 151
54 172
54 186
54 189
55 59
55 61
55 68
55 80
55 106
55 112
55 119
55 120
55 145
55 181
55 194
56 57
56 62
56 67
56 75
56 81
56 101
56 119
56 154
56 165
56 185
56 188
57 75
57 81
57 82
57 85
57 86
57 99
57 123
57 128
57 145
57 163
57 170
57 174
57 199
58 63
58 82
58 96
58 111
58 115
58 117
58 146
58 147
58 158
58 165
58 166
58 173
58 180
58 197
58 199
59 60
59 69
59 74
59 79
59 86
59 90
59 98
59 105
59 125
59 136
59 138
59 145
59 152
59 168
60 72
60 73
60 78
60 80
60 112
60 115
60 118
60 122
60 125
60 134
60 141
60 143
60 155
60 156
60 161
60 167
60 186
61 72
61 81
61 90
61 130
61 140
61 144
61 145
61 149
61 159
61 164
61 171
61 174
61 194
62 64
62 65
62 115
62 117
62 125
62 126
62 149
62 169
62 176
62 187
63 66
63 69
63 72
63 73
63 75
63 83
63 93
63 113
63 121
63 126
63 148
63 151
63 159
63 160
63 176
63 189
63 194
64 71
64 79
64 100
64 112
64 113
64 116
64 132
64 144
64 155
64 173
64 180
64 182
64 193
65 67
65 93
65 94
65 95
65 99
65 106
65 130
65 164
65 175
65 178
65 183
65 188
65 194
66 88
66 92
66 102
66 113
66 118
66 122
66 126
66 129
66 131
66 147
66 149
66 160
66 198
66 199
67 82
67 88
67 93
67 95
67 96
67 106
67 107
67 114
67 127
67 144
67 145
67 189
67 194
68 69
68 121
68 123
68 127
68 144
68 145
68 147
68 160
68 168
68 173
68 181
68 198
69 80
69 93
69 119
69 122
69 134
69 138
69 147
69 162
69 163
69 168
69 173
69 195
70 71
70 78
70 90
70 96
70 98
70 110
70 114
70 151
70 153
70 156
70 191
70 193
71 74
71 98
71 99
71 100
71 109
71 117
71 121
71 123
71 130
71 166
71 172
71 174
71 187
71 189
72 89
72 90
72 91
72 95
72 120
72 132
72 139
72 143
72 148
72 149
72 154
72 158
72 170
72 182
72 196
73 92
73 96
73 114
73 158
73 196
74 82
74 97
74 101
74 106
74 115
74 119
74 139
74 141
74 172
75 83
75 86
75 91
75 92
75 138
75 175
75 176
75 181
76 82
76 87
76 103
76 115
76 125
76 138
76 139
76 162
76 166
76 170
76 172
76 180
76 186
76 190
76 194
77 79
77 92
77 109
77 110
77 116
77 119
77 136
77 144
77 166
77 168
77 176
78 88
78 90
78 94
78 99
78 103
78 119
78 121
78 123
78 140
78 147
78 155
78 173
78 178
79 85
79 95
79 113
79 117
79 123
79 134
79 170
79 171
79 172
79 177
80 83
80 89
80 102
80 108
80 129
80 142
80 152
80 156
80 165
80 169
80 173
80 176
80 180
80 183
80 195
81 89
81 114
81 116
81 122
81 127
81 134
81 146
81 150
81 155
81 166
81 182
81 193
81 195
82 108
82 109
82 111
82 117
82 122
82 131
82 158
82 166
82 170
82 176
82 181
82 183
82 194
83 84
83 98
83 114
83 158
83 175
83 181
83 191
84 93
84 102
84 103
84 147
84 164
84 166
84 179
84 180
84 190
84 199
85 98
85 99
85 104
85 112
85 114
85 125
85 138
85 144
85 153
85 154
85 181
85 188
85 192
86 97
86 111
86 127
86 128
86 154
86 160
86 169
86 170
86 172
86 194
86 196
87 90
87 104
87 109
87 115
87 123
87 126
87 152
87 166
87 181
87 182
87 191
88 92
88 95
88 97
88 107
88 112
88 116
88 120
88 123
88 125
88 133
88 135
88 158
88 165
88 166
88 193
88 194
89 99
89 113
89 120
89 123
89 130
89 132
89 142
89 151
89 160
89 167
89 169
89 191
89 194
89 198
90 95
90 108
90 136
90 168
90 179
90 189
90 192
90 193
90 197
91 107
91 119
91 146
91 152
92 94
92 118
92 134
92 136
92 143
92 147
92 155
92 162
92 167
92 177
92 184
92 189
92 192
92 199
93 106
93 121
93 136
93 139
93 147
93 149
93 174
93 184
94 108
94 116
94 119
94 130
94 134
94 139
94 152
94 174
94 176
94 184
94 196
95 102
95 107
95 110
95 111
95 124
95 168
95 171
95 172
95 183
96 116
96 122
96 139
96 141
96 154
96 164
96 179
96 180
96 185
96 188
97 103
97 109
97 112
97 122
97 127
97 129
97 132
97 168
97 170
97 172
97 176
97 187
97 189
97 194
97 196
98 100
98 107
98 113
98 116
98 134
98 142
98 154
98 172
98 194
99 112
99 113
99 116
99 126
99 127
99 142
99 147
99 155
99 158
99 185
100 110
100 116
100 140
100 143
100 144
100 165
100 168
100 176
100 189
100 191
100 194
101 115
101 118
101 120
101 132
101 156
101 168
101 181
101 189
101 191
101 194
102 107
102 109
102 114
102 122
102 125
102 131
102 147
102 153
102 160
102 178
102 186
103 112
103 120
103 131
103 135
103 146
103 148
103 149
103 150
103 163
103 174
103 188
103 189
103 193
104 117
104 121
104 123
104 136
104 143
104 157
104 184
104 185
104 193
104 194
105 113
105 117
105 121
105 131
105 141
105 143
105 144
105 151
105 163
105 164
105 167
105 168
105 170
105 177
105 180
105 187
105 194
105 197
106 117
106 119
106 125
106 126
106 136
106 160
106 174
106 192
107 117
107 153
107 155
107 159
107 163
107 175
107 193
108 111
108 144
108 148
108 149
108 186
108 196
109 115
109 143
109 146
109 166
109 188
110 112
110 123
110 129
110 136
110 145
110 157
110 168
110 170
110 185
110 186
110 193
110 198
111 122
111 125
111 128
111 143
111 160
111 161
111 169
111 198
112 118
112 119
112 133
112 139
112 160
112 161
112 192
113 115
113 122
113 132
113 133
113 144
113 147
113 157
113 166
113 176
113 179
114 115
114 133
114 141
114 150
114 154
114 162
114 174
114 191
114 194
115 127
115 138
115 166
115 167
115 184
115 193
116 136
116 145
116 156
116 170
116 173
116 188
116 197
117 131
117 133
117 149
117 159
117 197
118 128
118 130
118 165
118 176
118 187
119 125
119 127
119 137
119 141
119 155
119 159
119 160
119 189
119 190
120 121
120 127
120 131
120 146
120 155
120 162
120 163
120 173
120 193
121 124
121 130
121 131
121 147
121 161
121 164
121 165
121 168
121 177
121 180
121 186
122 128
122 130
122 133
122 139
122 150
122 156
122 163
122 167
122 183
122 191
122 196
123 131
123 138
123 139
123 144
123 148
123 187
124 125
124 152
124 156
124 158
124 169
124 198
125 126
125 157
125 158
125 163
125 169
125 173
125 178
125 199
126 129
126 134
126 152
126 161
126 168
126 175
126 181
126 187
126 196
126 197
127 139
127 149
127 158
127 164
127 166
127 170
127 171
127 175
127 178
127 184
128 130
128 142
128 144
128 145
128 166
128 177
128 179
128 180
129 144
129 145
129 170
129 173
129 181
129 195
130 134
130 142
130 143
130 147
130 166
130 170
130 173
130 174
130 180
130 187
130 199
131 145
131 177
131 182
132 142
132 144
132 149
132 153
132 158
132 162
132 169
132 191
133 141
133 156
133 171
133 187
133 190
133 192
133 197
134 140
134 151
134 163
134 167
134 169
134 179
134 191
134 192
135 139
135 165
135 166
135 168
135 172
135 177
135 195
136 138
136 139
136 143
136 148
136 149
136 154
136 177
136 191
136 197
137 142
137 143
137 145
137 149
137 157
137 165
137 188
137 198
138 143
138 164
138 183
139 148
139 157
139 166
139 175
139 183
139 196
140 145
140 155
140 158
140 171
141 143
141 164
141 187
142 150
142 156
142 191
142 198
143 144
143 162
143 166
143 167
143 186
143 187
144 151
144 155
144 166
144 167
144 168
144 169
144 176
144 178
145 151
145 155
145 159
145 174
145 176
145 186
145 189
145 192
145 198
146 167
146 170
146 182
146 193
146 195
147 170
147 174
147 181
147 184
147 197
148 154
148 165
148 196
148 198
149 158
149 183
149 185
150 157
150 172
150 174
150 183
151 153
151 155
151 160
151 167
151 176
151 181
152 165
152 186
152 188
152 191
153 156
153 164
153 175
153 181
153 183
153 186
153 189
154 161
154 165
154 170
154 196
155 161
155 164
155 165
155 166
155 173
155 175
155 185
155 186
155 188
155 199
156 158
156 170
156 171
156 173
156 178
156 179
156 182
156 193
156 195
157 177
157 178
157 180
157 194
158 180
159 165
159 167
159 168
159 169
159 176
159 179
160 167
160 173
160 176
160 193
161 162
162 165
162 169
162 173
162 186
162 197
162 199
163 181
163 188
164 193
165 169
165 172
165 176
165 182
165 196
166 194
167 173
167 179
167 194
167 198
168 170
168 176
168 184
168 190
168 196
169 180
169 186
169 196
170 182
170 189
170 193
171 173
171 185
171 188
172 187
172 199
173 188
174 179
175 176
175 186
175 192
175 198
176 196
176 197
177 190
177 197
178 181
178 186
178 191
179 192
179 194
180 183
180 192
180 194
181 184
181 187
181 189
182 183
182 192
183 190
184 189
184 194
185 189
186 195
187 193
188 198
189 195
190 192
193 197
...@@ -17,6 +17,7 @@ class Network(): ...@@ -17,6 +17,7 @@ class Network():
self.links = {} #{(1,2):Link(1-2),(2,1):Link(2,1),(3,2):Link(3*2)} linkID = tuple(1,2) self.links = {} #{(1,2):Link(1-2),(2,1):Link(2,1),(3,2):Link(3*2)} linkID = tuple(1,2)
self.networkClockTime = 0 self.networkClockTime = 0
self.pk_weight_map = {} self.pk_weight_map = {}
self.time = 0
def setupNetwork(self): def setupNetwork(self):
''' '''
...@@ -33,20 +34,26 @@ class Network(): ...@@ -33,20 +34,26 @@ class Network():
w = randint(1, 51, 4) # 51 is excluded - range (1,50) w = randint(1, 51, 4) # 51 is excluded - range (1,50)
self.badaW = np.sum(w) self.badaW = np.sum(w)
i = 0 i = 0
with open('Nodes.dat', 'r') as f: with open('Nodes1.dat', 'r') as f:
reader = csv.reader(f) reader = csv.reader(f)
for row in reader: for row in reader:
node = row[0] # NOde id node = row[0] # Node id
xnode = {node:OverlayNode(node,self,w[i])} xnode = {node:OverlayNode(node,self,w[i])}
self.pk_weight_map.update({xnode[node].pk:w[i]}) self.pk_weight_map.update({xnode[node].pk:w[i]})
self.nodes.update(xnode)#added node to network self.nodes.update(xnode)#added node to network
# print(self.nodes.get('1')) #keys are strings # print(self.nodes.get('1')) #keys are strings
with open('Links.dat', 'r') as f: with open('Links1.dat', 'r') as f:
reader = csv.reader(f) reader = csv.reader(f)
for row in reader: for row in reader:
link = tuple(row[0].split()) # tuple of a link tup = row[0].split()
link = None # tuple of a link
if int(tup[0]) < int(tup[1]):
link = (tup[0],tup[1])
else:
link = (tup[1],tup[0])
linkDelay = 1 linkDelay = 1
self.links.update({link:Link(link,self,linkDelay)}) self.links.update({link:Link(link,self,linkDelay)})
...@@ -58,11 +65,17 @@ class Network(): ...@@ -58,11 +65,17 @@ class Network():
pass pass
def getLink(self,tup):
if int(tup[0]) < int(tup[1]) :
return self.links.get(tup)
else:
return self.links.get((tup[1],tup[0]))
def simulate(self,time): def simulate(self,time):
self.time = time
# logger.info("simulating .. ") # logger.info("simulating .. ")
self.networkClockTime = time self.networkClockTime = time
# Note links should be simulated before nodes # Note links should be simulated before nodeself.ResumeTasks.append(("nextOn", self.startNodeLifeCycleGenerator,))s
# in order to receive the messge which is supposed to be received in this tick # in order to receive the messge which is supposed to be received in this tick
for link in self.links.values(): for link in self.links.values():
link.simulate(time) link.simulate(time)
......
from SystemEntity import SystemEntity from SystemEntity import SystemEntity
import logging import logging
import Utility import Utility
import hashlib
from collections import defaultdict
class Node(SystemEntity): class Node(SystemEntity):
def __init__(self,id,network,weight): def __init__(self,id,network,weight):
...@@ -12,11 +14,14 @@ class Node(SystemEntity): ...@@ -12,11 +14,14 @@ class Node(SystemEntity):
self.adjacentNodes = [] self.adjacentNodes = []
self.messageQueue = [] self.messageQueue = []
self.sk,self.pk = Utility.genratePublicPrivateKey() self.sk,self.pk = Utility.genratePublicPrivateKey()
self.ResumeTasks = defaultdict(list)
'''make sure methods included here are not overriddenn''' '''make sure methods included here are not overriddenn'''
self.commands={"sendMessage":self.sendMessage, self.commands={"sendMessage":self.sendMessage,
"nextOn":self.nextOn "nextOn":self.nextOn
} }
self.messagesTillNow = [] # list of messages forwarded
self.uniqueReceivedMessages = defaultdict(list) #this is a list of messages in buffer which were not processed, expecting two list of 'BLOCK_PROPOSAL_MSG','PRIORITY_MSG'
def enqueMessage(self,message): def enqueMessage(self,message):
...@@ -42,25 +47,41 @@ class Node(SystemEntity): ...@@ -42,25 +47,41 @@ class Node(SystemEntity):
:param params: ('1','2','hello2') :param params: ('1','2','hello2')
:return: :return:
''' '''
link = self.network.links.get((params[0],params[1])) link = self.network.getLink((params[0],params[1]))
link.enqueMessage((time,params)) link.enqueMessage((time,params))
self.logger.info("Sending : " + str((time,params))) # any message going out is recorded as sent and will be checked for duplicates
self.messagesTillNow.append(hashlib.sha256((str(params[2])).encode('utf-8')).hexdigest())
###### self.logger.info("Sending : " + str((time,params)))#(time,(sender,receiver,payload))
pass pass
def broadcast(self,time,gossipPayload): def broadcast(self,time,gossipPayload):
for node in self.adjacentNodes: '''
link = self.network.links.get((self.id, node.id))
:param time:
:param gossipPayload:
:return:
broadcast and processMessage together makes it gossip protocol
'''
self.messagesTillNow.append(hashlib.sha256((str(gossipPayload)).encode('utf-8')).hexdigest())
for nodeid in self.adjacentNodes:
node = self.network.nodes.get(nodeid)
link = self.network.getLink((self.id, node.id))
link.enqueMessage((time, (self.id, node.id,gossipPayload))) link.enqueMessage((time, (self.id, node.id,gossipPayload)))
self.logger.info("Sending : " + str((time, (self.id, node.id,gossipPayload)))) ###### self.logger.info("Sending : " + str((time, (self.id, node.id,gossipPayload))))#(time,(sender,receiver,payload))
def processMessage(self,time,payload): def processMessage(self,time,payload):
print("fianlly reached : " + str(payload))
'''remove any extra headers like source and destination here ''' '''remove any extra headers like source and destination here '''
payload.pop(0) # removed source header payload.pop(0) # removed source header
payload.pop(0) #removed destination header payload.pop(0) #removed destination header
# TODO check messages for duplicates and brodacast them : Done
if not (hashlib.sha256((str(payload[0])).encode('utf-8')).hexdigest() in self.messagesTillNow) :
self.broadcast(time,payload[0])
self.uniqueReceivedMessages[payload[0][0]].append(payload[0])
def nextOn(self,time,generator): def nextOn(self,time,generator):
next(generator[0]) return next(generator[0])
def startNodeLifeCycle(self): def startNodeLifeCycle(self):
pass pass
...@@ -83,6 +104,28 @@ class Node(SystemEntity): ...@@ -83,6 +104,28 @@ class Node(SystemEntity):
self.logger.info("received : "+str(message)) self.logger.info("received : "+str(message))
self.dequeMessage() self.dequeMessage()
# check if main ba* has to be resumed or not
try:
ResumeTasks = self.ResumeTasks.pop(time)
for ResumeTask in ResumeTasks:
command = self.commands.get(ResumeTask[0])
ResumeOut = command(time,ResumeTask[1:])
'''
synatx for proper return commands
yield "resume",timeafter_which_to_resume
'''
if ResumeOut and ResumeOut[0] == "resume":
self.logger.info("resume has been called")
self.ResumeTasks[str(int(time)+int(ResumeOut[1]))].append(("nextOn", self.startNodeLifeCycleGenerator,))
except KeyError as ke:
# not task pending at this time
pass
except StopIteration as si:
pass
except IndexError as Ie:
self.logger.info("No resume task from ba*")
# TODO : perform task from todolist which are relevant for current tick # TODO : perform task from todolist which are relevant for current tick
...@@ -91,14 +134,9 @@ class Node(SystemEntity): ...@@ -91,14 +134,9 @@ class Node(SystemEntity):
for task in tasks: for task in tasks:
command = self.commands.get(task[0]) command = self.commands.get(task[0])
out = command(time,task[1:]) out = command(time,task[1:])
if out and out[0] == "resume":
self.logger.info("resume has been called")
self.todoList[time+1].append(("nextOn", self.startNodeLifeCycleGenerator,))
except KeyError as ke: except KeyError as ke:
# not task pending at this time # not task pending at this time
pass pass
except StopIteration as si:
pass
......
...@@ -2,3 +2,6 @@ ...@@ -2,3 +2,6 @@
2 2
3 3
4 4
5
6
7
\ No newline at end of file
...@@ -48,153 +48,3 @@ ...@@ -48,153 +48,3 @@
47 47
48 48
49 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
...@@ -2,19 +2,92 @@ from Node import Node ...@@ -2,19 +2,92 @@ from Node import Node
import logging import logging
import Utility import Utility
import hashlib import hashlib
import Config
import random
from ecdsa import SigningKey,SECP256k1
from ecdsa.keys import BadSignatureError
genesisBlock = "I am the first block" genesisBlock = ("I am the first block")
#
# class Role:
# def __init__(self):
# self.role =
class OverlayNode(Node): class OverlayNode(Node):
def __init__(self,id,network,weight): def __init__(self,id,network,weight):
Node.__init__(self,id,network,weight) Node.__init__(self,id,network,weight)
self.blockchain = [genesisBlock]
self.currentRound = 1 # round is equivalent ot block height
self.step = 0
self.currentRoleCount = 20
self.currentRole = "BLOCK_PROPOSER"
self.currentSeed = None
self.startNodeLifeCycleGenerator = self.startNodeLifeCycle() self.startNodeLifeCycleGenerator = self.startNodeLifeCycle()
# adding initial task of bootstraping node.and it only contains ba* resume tasks
# self.ResumeTasks.append(("nextOn", self.startNodeLifeCycleGenerator,))
self.ResumeTasks['1'].append(("nextOn", self.startNodeLifeCycleGenerator,))
self.commands.update({}) self.commands.update({})
def processMessage(self,time,payload):
super(OverlayNode, self).processMessage(time,payload)
print("from overlay node : "+str(payload))
# def processMessage(self,time,payload):
# super(OverlayNode, self).processMessage(time,payload)
# print("from overlay node : "+str(payload))
def algo_processMsg(self,msg,tou):
pk = msg[1][0]
sign = msg[1][2]
payload = msg[1][1]
try:
pk.verify(sign,bytes(str(payload).encode('UTF8')) )
except BadSignatureError as badSign:
print("bad signature")
return 0,None,None
round, step, sorthash, proof, previousblockHash, value = payload
if previousblockHash != hashlib.sha256(self.blockchain[-1].encode('utf-8')).hexdigest() :
print("not in the right chain")
return 0, None, None
seed = self.currentSeed
role= (Config.ROLE_COMMITEE_FOR_VOTE, round, step)
# Todo something is wrong here not getting correct votes back
votes = Utility.verifySort(pk, sorthash, proof, seed, tou, role, self.network.pk_weight_map.get(pk), self.network.badaW)
print("why votes be zero")
print(votes,"\t",value,"\t",sorthash)
return votes,value,sorthash
pass
def partOfCountVotes(self,round,step,start,counts,voters,T,tou):
msgs = self.uniqueReceivedMessages.pop(Config.COMMITTEE_VOTE_MSG_type)
for msg in msgs:
msg_round = msg[1][1][0]
msg_step = msg[1][1][1]
payload = msg[1][1]
msg_pk = msg[1][0]
# print(round, " # ",step )
if msg_round== round and msg_step==step : #check if message belong to current round and current step or not
votes,value,sorthash = self.algo_processMsg(msg,tou)
if msg_pk in voters or votes == 0:
print(self.id + " continuing")
continue
voters.append(msg_pk)
counts[value] = counts[value]+ votes
if counts[value] > T*tou :
print("returning value")
return value
pass
else:
self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type].append(msg)
pass
pass
def startNodeLifeCycle(self): def startNodeLifeCycle(self):
'''THis is monolithic algorand algorithm for a NOde''' '''THis is monolithic algorand algorithm for a NOde'''
self.logger.info("Life cycle started") self.logger.info("Life cycle started")
...@@ -23,29 +96,22 @@ class OverlayNode(Node): ...@@ -23,29 +96,22 @@ class OverlayNode(Node):
#increment round number #increment round number
blockForBA = None
# Checking if I am a Block Propser # Checking if I am a Block Propser
previousHash = hashlib.sha256(genesisBlock.encode('utf-8')).hexdigest() previousHash = hashlib.sha256(self.blockchain[-1].encode('utf-8')).hexdigest()
currentRound = 0 seed = ( previousHash,self.currentRound,0)
step = 0 self.currentSeed= (previousHash, self.currentRound, 0)
blockHeight = 0 hash, proof, j = Utility.sortition(self.sk,seed,Config.tou_proposer, Config.ROLE_BLOCK_PROPOSER, self.weight, self.network.badaW, self.pk)
seed = ( previousHash,currentRound,blockHeight )
roleCount = 20
role = "BLOCK_PROPOSER" if j > 0 : # only the block proposer commity mebers can enter here
w = self.weight self.logger.info("selection for BLOCK PROPOSAL with J ="+str( j))
badaW = 100
hash, proof, j = Utility.sortition(self.sk,seed,roleCount, role, w, self.network.badaW, self.pk)
print("I am the mighty J =",j)
if j > 0 :
min_sha_priority = None min_sha_priority = None
# min_sub_user_index = None # min_sub_user_index = None
# msg_to_broadcast = ( currentRound, hash , min_sub_user_index , min_sha_priority ) # msg_to_broadcast = ( currentRound, hash , min_sub_user_index , min_sha_priority )
print(w) for sub_user_index in range(self.weight):
print(range(w)) input_to_SHA256 = (hash , sub_user_index,)
for sub_user_index in range(w):
input_to_SHA256 = (hash , sub_user_index,) # TODO : can concatenation means this
sha256_hash = hashlib.sha256((str(input_to_SHA256)).encode('utf-8')).hexdigest() sha256_hash = hashlib.sha256((str(input_to_SHA256)).encode('utf-8')).hexdigest()
print(sha256_hash)
if not min_sha_priority : if not min_sha_priority :
min_sha_priority = sha256_hash min_sha_priority = sha256_hash
min_sub_user_index = sub_user_index min_sub_user_index = sub_user_index
...@@ -54,15 +120,224 @@ class OverlayNode(Node): ...@@ -54,15 +120,224 @@ class OverlayNode(Node):
min_sub_user_index = sub_user_index min_sub_user_index = sub_user_index
msg_to_broadcast = ( currentRound, hash , min_sub_user_index , min_sha_priority ) priority_msg_to_broadcast = ( Config.PRIORITY_MSG_type,self.currentRound, hash , min_sub_user_index , min_sha_priority,proof )
print(msg_to_broadcast) self.logger.info("broadcsting priority message : "+str(priority_msg_to_broadcast))
self.logger.info(msg_to_broadcast) self.broadcast(self.network.time, priority_msg_to_broadcast)
print("i am before yield 1",self.id) self.logger.info("WAITING FOR PRIORITY MESSAGES from others")
yield "resume" yield "resume",Config.lambda_proposer
print("i am before yield 2", self.id)
yield
greater_flag = True
msgs = self.uniqueReceivedMessages.pop(Config.PRIORITY_MSG_type)
for priority_msg_other in msgs :
if min_sha_priority > priority_msg_other[4]:
greater_flag = False
if greater_flag :
self.logger.info("I am the block proposer")
'''
BLOCK_PROPOSAL_MSG_to_broadcast : ("BLOCK_PROPOSAL_MSG", previousblockhash,A random string as txns,Nod`s priority payload)
'''
BLOCK_PROPOSAL_MSG_to_broadcast = (Config.BLOCK_PROPOSAL_MSG_type, previousHash,Utility.pseudoRandomGenerator(random.randint(0,1000)),priority_msg_to_broadcast[1:])
self.logger.info("broadcsting BLOCK Proposal Message : " + str(BLOCK_PROPOSAL_MSG_to_broadcast))
self.broadcast(self.network.time, BLOCK_PROPOSAL_MSG_to_broadcast)
blockForBA = (previousHash,BLOCK_PROPOSAL_MSG_to_broadcast[2])
else: # others than block proposers
# everybody except highest priority block proposer is waiting for lambda_proposer+ lambda_block 33 seconds
yield "resume", Config.lambda_proposer + Config.lambda_block
else: # others than block proposers
# everybody is waiting for lambda_proposer+ lambda_block 33 seconds
yield "resume", Config.lambda_proposer+Config.lambda_block
# TODO:done : drop any priority messages in queue
try :
self.uniqueReceivedMessages.pop(Config.PRIORITY_MSG_type)
except Exception:
pass
######### Performing selection of block BA* ############################
if not (self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type] or blockForBA) :
blockForBA = (previousHash,"Empty")
elif not blockForBA :
# Todo select block from highest priority node
blockForBA = (self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type][0][1],
self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type][0][2])
pk = self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type][0][3][4]
hash = self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type][0][3][1]
proof = self.uniqueReceivedMessages[Config.BLOCK_PROPOSAL_MSG_type][0][3][4]
w = self.network.pk_weight_map.get(pk)
seed = (previousHash, self.currentRound, 0)
# TODO verify block proposal
j = Utility.verifySort(pk, hash, proof, seed, Config.tou_proposer, Config.ROLE_BLOCK_PROPOSER, w, self.network.badaW)
if j :
self.logger.info("it is a valid block proposed message with j : "+str(j))
#todo : DONE : drop block proposal msges
try :
self.uniqueReceivedMessages.pop(Config.BLOCK_PROPOSAL_MSG_type)
except Exception as e:
self.logger.error(e)
# print(blockForBA)
hashof_blockForBA = Utility.pseudoRandomGenerator(blockForBA)
######### END : Performing selection of block BA* ############################
''' START : REDUCTION ALGORITHM '''
''' COmmitte vote reduction step 1'''
reduct_step_1 = 1
reduct_seed = (previousHash, self.currentRound, reduct_step_1)
reduct_role_1 = (Config.ROLE_COMMITEE_FOR_VOTE,self.currentRound,reduct_step_1)
reduct_sorthash, reduct_proof, reduct_j = Utility.sortition(self.sk, reduct_seed, Config.tou_step, reduct_role_1,
self.weight, self.network.badaW, self.pk)
# print("Reduction algo " + self.id," : ",reduct_j)
if reduct_j > 0:
self.logger.info("selection for VOTING COMMITEE with J =" + str(reduct_j))
payload = (self.currentRound,reduct_step_1,reduct_sorthash,reduct_proof,previousHash,hashof_blockForBA)
committeeVoteMsg = (Config.COMMITTEE_VOTE_MSG_type,(self.pk,payload,self.sk.sign(bytes(str(payload).encode('UTF8')))))
self.broadcast(self.network.time,committeeVoteMsg)
self.logger.info("Broadcasting commitee messgae"+str(committeeVoteMsg))
# print(self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type])
yield "resume",Config.lambda_block+Config.lambda_step
######## count votes for hblock1 ###########
countVote_round = self.currentRound
countVote_reduct_step_1 = 1
# Config.T
# Config.tou_step
countVote_lmbda = Config.lambda_block+Config.lambda_step
start = int(self.network.time)
counts = {}
voters = []
hblock1 = None
while True:
if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type] :
if int(self.network.time) > start + countVote_lmbda:
print(self.id + "Timing out")
hblock1 = Config.TIMEOUT
break
pass
else:
temp_return = self.partOfCountVotes(countVote_round,countVote_reduct_step_1,start,counts,voters,Config.T,Config.tou_step)
print("temp_retiurn " ,temp_return)
if temp_return :
hblock1 = temp_return
break
yield "resume",1 # this is to allow other nodes to be simulated and not get this node into infinite waiting on single node
self.logger.info("returning from first count values with return value : "+str(hblock1))
print("returning from first count values with return value",hblock1)
######## END : count votes for hblock1 ###########
''' END : COmmitte vote reduction step 1'''
''' Start : COmmitte vote reduction step 2 '''
empty_hash = Utility.pseudoRandomGenerator((previousHash, "Empty"))
# which block to vote empty or hblock1
reduct_step2_block_to_vote = None
if hblock1 == Config.TIMEOUT :
reduct_step2_block_to_vote = empty_hash
pass
else:
reduct_step2_block_to_vote = hblock1
pass
''' COmmitte vote reduction step2 : reduct_step2_block_to_vote'''
variables_reduct_step_2 = {}
variables_reduct_step_2['step'] = 2
variables_reduct_step_2['seed'] = (previousHash, self.currentRound, variables_reduct_step_2['step'])
variables_reduct_step_2['role'] = (
Config.ROLE_COMMITEE_FOR_VOTE, self.currentRound, variables_reduct_step_2['step'])
variables_reduct_step_2['sorthash'], variables_reduct_step_2['proof'], variables_reduct_step_2[
'j'] = Utility.sortition(self.sk, variables_reduct_step_2['seed'],
Config.tou_step,
variables_reduct_step_2['role'],
self.weight, self.network.badaW,
self.pk)
# print("Reduction algo " + self.id," : ",reduct_j)
if variables_reduct_step_2['j'] > 0:
self.logger.info("selection for VOTING COMMITEE with J =" + str(variables_reduct_step_2['j']))
variables_reduct_step_2['payload'] = (
self.currentRound, variables_reduct_step_2['step'], variables_reduct_step_2['sorthash'],
variables_reduct_step_2['proof'], previousHash, reduct_step2_block_to_vote)
variables_reduct_step_2['committeeVoteMsg'] = (Config.COMMITTEE_VOTE_MSG_type,
(self.pk, variables_reduct_step_2['payload'],
self.sk.sign(bytes(
str(variables_reduct_step_2['payload']).encode(
'UTF8')))))
self.broadcast(self.network.time, variables_reduct_step_2['committeeVoteMsg'])
self.logger.info("Broadcasting commitee messgae" + str(variables_reduct_step_2['committeeVoteMsg']))
# yield "resume", Config.lambda_block + Config.lambda_step
''' COmmitte vote reduction step2 : reduct_step2_block_to_vote'''
######## count votes for hblock1 ###########
CountVotes_step2 = {}
CountVotes_step2['countVote_round'] = self.currentRound
CountVotes_step2['countVote_step'] = 1
# Config.T
# Config.tou_step
CountVotes_step2['countVote_lmbda'] = Config.lambda_block + Config.lambda_step
CountVotes_step2['start'] = int(self.network.time)
CountVotes_step2['counts'] = {}
CountVotes_step2['voters'] = []
CountVotes_step2['hblock2'] = None
while True:
if not self.uniqueReceivedMessages[Config.COMMITTEE_VOTE_MSG_type]:
if int(self.network.time) > CountVotes_step2['start'] + CountVotes_step2[
'countVote_lmbda']:
print(self.id + "Timing out")
CountVotes_step2['hblock2'] = Config.TIMEOUT
break
pass
else:
CountVotes_step2['temp_return'] = self.partOfCountVotes(
CountVotes_step2['countVote_round'], CountVotes_step2['countVote_step'],
CountVotes_step2['start'], CountVotes_step2['counts'],
CountVotes_step2['voters'], Config.T, Config.tou_step)
print("CountVotes_step2",CountVotes_step2['temp_return'])
if CountVotes_step2['temp_return']:
CountVotes_step2['hblock2'] = CountVotes_step2['temp_return']
break
yield "resume", 1 # this is to allow other nodes to be simulated and not get this node into infinite waiting on single node
self.logger.info(
"returning from first count values with return value : " + str(CountVotes_step2['hblock2']))
print("CountVotes_step2",CountVotes_step2['hblock2'])
######## END : count votes for hblock1 ###########
var_BBA_star = {}
if CountVotes_step2['hblock2'] == Config.TIMEOUT:
var_BBA_star['block_hash']= empty_hash
else:
var_BBA_star['block_hash'] = CountVotes_step2['hblock2']
print("I am culprit " ,var_BBA_star['hblock2'])
''' END : COmmitte vote reduction step 2 '''
yield "resume", 9
# self.logger.info(self.uniqueReceivedMessages)
yield "resume",40000
''' END : REDUCTION ALGORITHM '''
''' '''
TODo check if node is selected as BLOCK_PROPOSER TODo check if node is selected as BLOCK_PROPOSER
if yes if yes
...@@ -114,8 +389,16 @@ class OverlayNode(Node): ...@@ -114,8 +389,16 @@ class OverlayNode(Node):
def m(v):
v.append('ganesh')
if __name__ == '__main__':
x = 2
if True:
x = 3
print(x)
print(x)
...@@ -144,46 +427,3 @@ class OverlayNode(Node): ...@@ -144,46 +427,3 @@ class OverlayNode(Node):
class A(object):
def __init__(self,id):
self.id = id
self.commands = {"sendMessage": self.sendMessage,
}
def sendMessage(self):
pass
def process(self,param):
print("from A " +str(param) )
param.pop(0)
param.pop(0)
class B(A):
def __init__(self,id):
A.__init__(self, id)
self.commands.update({"hello":self.working})
def working(self):
pass
def process(self,param):
super(B, self).process(param)
print("from B" + str(param))
if __name__ == '__main__':
l = (1,2,tuple(str('3|4|5').split('|')))
x = B(2)
print(x.commands)
x.process(list(l))
...@@ -12,6 +12,6 @@ if __name__ == '__main__': ...@@ -12,6 +12,6 @@ if __name__ == '__main__':
metronome = TimeSimulator() metronome = TimeSimulator()
network = Network() network = Network()
network.setupNetwork() network.setupNetwork()
populateTodolist(network) # populateTodolist(network)
metronome.startTicking(network.simulate) metronome.startTicking(network.simulate)
pass pass
\ No newline at end of file
...@@ -22,3 +22,4 @@ class SystemEntity(object): ...@@ -22,3 +22,4 @@ class SystemEntity(object):
''' '''
pass pass
...@@ -18,11 +18,12 @@ def populateTodolist(net): ...@@ -18,11 +18,12 @@ def populateTodolist(net):
instruction = row[0].split() # tuple of a link instruction = row[0].split() # tuple of a link
node = network.nodes.get(instruction[0]) node = network.nodes.get(instruction[0])
node.todoList[instruction[1]].append(tuple(instruction[2:])) node.todoList[instruction[1]].append(tuple(instruction[2:]))
for id, node in network.nodes.items(): # for id, node in network.nodes.items():
node.todoList['0'].append(("nextOn",node.startNodeLifeCycleGenerator,)) # node.todoList['0'].append(("nextOn",node.startNodeLifeCycleGenerator,))
for id,node in network.nodes.items(): for id,node in network.nodes.items():
logger.info(id +" : "+str(node.todoList)) # logger.info(id +" : "+str(node.todoList))
pass
def simulateNetwork(net): def simulateNetwork(net):
if not net: if not net:
...@@ -41,6 +42,11 @@ def simulateNetwork(net): ...@@ -41,6 +42,11 @@ def simulateNetwork(net):
if __name__ == '__main__': if __name__ == '__main__':
logging.basicConfig(filename='TestCases.log', level=logging.INFO) logging.basicConfig(filename='TestCases.log', level=logging.INFO)
# populateTodolist(None) # populateTodolist(None)
simulateNetwork(None) # simulateNetwork(None)
ak = ['hello','ramesh']
ak.append('rao')
if 'hello' in ak:
print("yay")
print(ak.pop())
pass pass
...@@ -155,6 +155,13 @@ class TestYieldSequence: ...@@ -155,6 +155,13 @@ class TestYieldSequence:
self.B() self.B()
self.C() self.C()
def gen():
for i in range(5):
yield 'ram', 'ganesh'
def testit():
for k1 in gen():
print(k1[1])
if __name__ == '__main__': if __name__ == '__main__':
# testSortition() # testSortition()
...@@ -162,5 +169,5 @@ if __name__ == '__main__': ...@@ -162,5 +169,5 @@ if __name__ == '__main__':
# testVerifySort( # testVerifySort(
# testclassLessGenerator() # testclassLessGenerator()
# testGeneratorClass() # testGeneratorClass()
testSelfReferGen() # testSelfReferGen()
testit()
...@@ -12,7 +12,7 @@ class TimeSimulator(object): ...@@ -12,7 +12,7 @@ class TimeSimulator(object):
return "Time : "+ str(self._systemTime) return "Time : "+ str(self._systemTime)
def startTicking(self,callback): def startTicking(self,callback):
for i in range(10): for i in range(10000):
self._systemTime = self._systemTime + 1 self._systemTime = self._systemTime + 1
logger.info(self) logger.info(self)
callback(str(self._systemTime)) callback(str(self._systemTime))
......
...@@ -2,8 +2,6 @@ import hashlib ...@@ -2,8 +2,6 @@ import hashlib
from numpy.random import randint from numpy.random import randint
import sys import sys
import networkx as nx import networkx as nx
import numpy
import matplotlib.pyplot as plt
from networkx.algorithms import community from networkx.algorithms import community
''' '''
......
1 5 sendMessage 1 2 hello2 1 5 sendMessage 1 2 hello2
2 3 sendMessage 2 3 hello3
4 5 sendMessage 4 1 hello1
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