-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.py
58 lines (49 loc) · 1.79 KB
/
Utils.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
import configparser, getopt
from time import time
import sys
def readWalletInformation(configurationFile):
config = configparser.ConfigParser()
config.read(configurationFile)
sections = config.sections()
MAIN_WALLET = config[sections[0]]['MAIN_WALLET']
KEY = config[sections[0]]['KEY']
return MAIN_WALLET, KEY
def readNodeConnection(configurationFile):
config = configparser.ConfigParser()
config.read(configurationFile)
sections = config.sections()
IPC_PATH = config[sections[1]]['IPC_PATH']
if IPC_PATH != 0:
return IPC_PATH, 'IPC_PATH'
HTTP_PROVIDER = config[sections[1]]['HTTP_PROVIDER']
if HTTP_PROVIDER != 0:
return HTTP_PROVIDER, 'HTTP_PROVIDER'
WEB_SOCKET = config[sections[1]]['WEB_SOCKET']
if WEB_SOCKET != 0:
return WEB_SOCKET, 'WEB_SOCKET'
return 0, 0
def exportWallets(WalletsPasswords):
with open(f"Wallets_{time()}.txt", "w") as f:
for wallet in WalletsPasswords:
f.write(wallet + "\t" + WalletsPasswords[wallet] + "\n")
f.close()
def readArguments(argv):
numberOfWallets = False
receiverWallets = False
transactionsPerSecond = False
transactionSize = False
try:
opts, args = getopt.getopt(argv, "n:r:t:s:")
except getopt.GetoptError as error:
print('Main.py -n <numberOfWallets> -r <receiverWallet1,receiverWallet2,...> -t <transactionsPerSecond> -s <transactionSize>')
sys.exit(2)
for opt, arg in opts:
if opt == '-n':
numberOfWallets = int(arg)
elif opt == '-r':
receiverWallets = arg.split(',')
elif opt == '-t':
transactionsPerSecond = int(arg)
elif opt == '-s':
transactionSize = int(arg)
return numberOfWallets, receiverWallets, transactionsPerSecond, transactionSize