-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
61 lines (54 loc) · 1.52 KB
/
Main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
import ecdsa
from ecdsa import SigningKey
from Transaction import Transaction
import random, time
from threading import Thread
from Miner import Miner
from Simulation import Simulation
import NetMiner
import SPV_net
from time import sleep
def main():
# SPVs running on 5007-5009
start_spv()
sleep(0.5)
start_51miners()
#start_selfishminers()
while True:
try:
pass
except:
pass
def start_normalminers(num=5):
for x in range(5000, 5001+num):
td = Thread(target=NetMiner.start_all_stuff, args=(x,1,False,False,))
td.setDaemon(True)
td.start()
def start_51miners(num=5):
diffs = [1,5,5,5,5,5]
for x,d in zip(range(0,num+1), diffs):
if x==0:
trydospending=True
else:
trydospending= False
td = Thread(target=NetMiner.start_all_stuff, args=(5000+x,d,False,trydospending,))
td.setDaemon(True)
td.start()
def start_spv(num=3):
ports = [5007, 5008, 5009]
for p in ports:
td = Thread(target=SPV_net.start_SPV, args=(p,))
td.setDaemon(True)
td.start()
def start_selfishminers(num=5):
diffs = [1,5,5,5,5,5]
for x,d in zip(range(0,num+1), diffs):
if x==0:
selfish=True
else:
selfish= False
td = Thread(target=NetMiner.start_all_stuff, args=(5000+x,d,selfish,False,))
td.setDaemon(True)
td.start()
if __name__ == '__main__':
main()