2021-01-08 13:10:38 +01:00
|
|
|
"""
|
|
|
|
Create random address
|
|
|
|
"""
|
|
|
|
|
|
|
|
import time
|
|
|
|
import defaults
|
|
|
|
import queues
|
|
|
|
import state
|
|
|
|
|
|
|
|
from bmconfigparser import BMConfigParser
|
|
|
|
|
|
|
|
|
|
|
|
def checkHasNormalAddress():
|
|
|
|
"""method for checking address"""
|
2021-01-08 18:28:58 +01:00
|
|
|
for address in BMConfigParser().addresses():
|
|
|
|
|
|
|
|
if BMConfigParser().safeGetBoolean(address, 'enabled'):
|
2021-01-08 13:10:38 +01:00
|
|
|
return address
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
def createAddressIfNeeded(label_text, streamNumberForAddress=1):
|
|
|
|
"""method for creating random address"""
|
|
|
|
if not checkHasNormalAddress():
|
|
|
|
queues.addressGeneratorQueue.put((
|
|
|
|
'createRandomAddress', 4, streamNumberForAddress,
|
|
|
|
label_text,
|
|
|
|
1, "", False,
|
|
|
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte,
|
|
|
|
defaults.networkDefaultPayloadLengthExtraBytes
|
|
|
|
))
|
2021-01-08 18:28:58 +01:00
|
|
|
start_time = time.time()
|
2021-01-13 09:44:26 +01:00
|
|
|
while int(time.time() - start_time) < 10 and state.shutdown == 0 and not checkHasNormalAddress():
|
2021-01-08 13:10:38 +01:00
|
|
|
time.sleep(.2)
|
|
|
|
return checkHasNormalAddress()
|