This repository has been archived on 2024-12-19. You can view files and clone it, but cannot push or open issues or pull requests.
PyBitmessage-2024-12-19/src/helper_addressGenerator.py

36 lines
984 B
Python
Raw Normal View History

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()