Merge branch 'v0.6' of https://github.com/Bitmessage/PyBitmessage into v0.6
This commit is contained in:
commit
fccec36649
35
src/helper_addressGenerator.py
Normal file
35
src/helper_addressGenerator.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
"""
|
||||||
|
Create random address
|
||||||
|
"""
|
||||||
|
|
||||||
|
import time
|
||||||
|
import defaults
|
||||||
|
import queues
|
||||||
|
import state
|
||||||
|
|
||||||
|
from bmconfigparser import BMConfigParser
|
||||||
|
|
||||||
|
|
||||||
|
def checkHasNormalAddress():
|
||||||
|
"""method for checking address"""
|
||||||
|
for address in BMConfigParser().addresses():
|
||||||
|
|
||||||
|
if BMConfigParser().safeGetBoolean(address, 'enabled'):
|
||||||
|
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
|
||||||
|
))
|
||||||
|
start_time = time.time()
|
||||||
|
while int(time.time() - start_time) < 10 and state.shutdown == 0 and not checkHasNormalAddress():
|
||||||
|
time.sleep(.2)
|
||||||
|
return checkHasNormalAddress()
|
|
@ -291,7 +291,6 @@ def init():
|
||||||
global bitmsglib, bmpow
|
global bitmsglib, bmpow
|
||||||
|
|
||||||
openclpow.initCL()
|
openclpow.initCL()
|
||||||
|
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
if ctypes.sizeof(ctypes.c_voidp) == 4:
|
if ctypes.sizeof(ctypes.c_voidp) == 4:
|
||||||
bitmsglib = 'bitmsghash32.dll'
|
bitmsglib = 'bitmsghash32.dll'
|
||||||
|
@ -305,8 +304,7 @@ def init():
|
||||||
bmpow.restype = ctypes.c_ulonglong
|
bmpow.restype = ctypes.c_ulonglong
|
||||||
_doCPoW(2**63, "")
|
_doCPoW(2**63, "")
|
||||||
logger.info("Successfully tested C PoW DLL (stdcall) %s", bitmsglib)
|
logger.info("Successfully tested C PoW DLL (stdcall) %s", bitmsglib)
|
||||||
except:
|
except ValueError:
|
||||||
logger.error("C PoW test fail.", exc_info=True)
|
|
||||||
try:
|
try:
|
||||||
# MinGW
|
# MinGW
|
||||||
bso = ctypes.CDLL(os.path.join(paths.codePath(), "bitmsghash", bitmsglib))
|
bso = ctypes.CDLL(os.path.join(paths.codePath(), "bitmsghash", bitmsglib))
|
||||||
|
@ -315,8 +313,11 @@ def init():
|
||||||
bmpow.restype = ctypes.c_ulonglong
|
bmpow.restype = ctypes.c_ulonglong
|
||||||
_doCPoW(2**63, "")
|
_doCPoW(2**63, "")
|
||||||
logger.info("Successfully tested C PoW DLL (cdecl) %s", bitmsglib)
|
logger.info("Successfully tested C PoW DLL (cdecl) %s", bitmsglib)
|
||||||
except:
|
except Exception as e:
|
||||||
logger.error("C PoW test fail.", exc_info=True)
|
logger.error("Error: %s", e, exc_info=True)
|
||||||
|
bso = None
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("Error: %s", e, exc_info=True)
|
||||||
bso = None
|
bso = None
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
|
Reference in New Issue
Block a user