def init(): """Initialise PoW""" # pylint: disable=global-statement global bitmsglib, bmpow openclpow.initCL() if sys.platform == "win32": if ctypes.sizeof(ctypes.c_voidp) == 4: bitmsglib = 'bitmsghash32.dll' else: bitmsglib = 'bitmsghash64.dll' try: # MSVS bso = ctypes.WinDLL(os.path.join(paths.codePath(), "bitmsghash", bitmsglib)) logger.info("Loaded C PoW DLL (stdcall) %s", bitmsglib) bmpow = bso.BitmessagePOW bmpow.restype = ctypes.c_ulonglong _doCPoW(2**63, "") logger.info("Successfully tested C PoW DLL (stdcall) %s", bitmsglib) except: logger.error("C PoW test fail.", exc_info=True) try: # MinGW bso = ctypes.CDLL(os.path.join(paths.codePath(), "bitmsghash", bitmsglib)) logger.info("Loaded C PoW DLL (cdecl) %s", bitmsglib) bmpow = bso.BitmessagePOW bmpow.restype = ctypes.c_ulonglong _doCPoW(2**63, "") logger.info("Successfully tested C PoW DLL (cdecl) %s", bitmsglib) except: logger.error("C PoW test fail.", exc_info=True) bso = None else: try: bso = ctypes.CDLL(os.path.join(paths.codePath(), "bitmsghash", bitmsglib)) except OSError: import glob try: bso = ctypes.CDLL(glob.glob(os.path.join( paths.codePath(), "bitmsghash", "bitmsghash*.so" ))[0]) except (OSError, IndexError): bso = None except: bso = None else: logger.info("Loaded C PoW DLL %s", bitmsglib) if bso: try: bmpow = bso.BitmessagePOW bmpow.restype = ctypes.c_ulonglong except: bmpow = None else: bmpow = None if bmpow is None: buildCPoW()
def init(): global bitmsglib, bso, bmpow openclpow.initCL() if "win32" == sys.platform: if ctypes.sizeof(ctypes.c_voidp) == 4: bitmsglib = 'bitmsghash32.dll' else: bitmsglib = 'bitmsghash64.dll' try: # MSVS bso = ctypes.WinDLL(os.path.join(paths.codePath(), "bitmsghash", bitmsglib)) logger.info("Loaded C PoW DLL (stdcall) %s", bitmsglib) bmpow = bso.BitmessagePOW bmpow.restype = ctypes.c_ulonglong _doCPoW(2**63, "") logger.info("Successfully tested C PoW DLL (stdcall) %s", bitmsglib) except: logger.error("C PoW test fail.", exc_info=True) try: # MinGW bso = ctypes.CDLL(os.path.join(paths.codePath(), "bitmsghash", bitmsglib)) logger.info("Loaded C PoW DLL (cdecl) %s", bitmsglib) bmpow = bso.BitmessagePOW bmpow.restype = ctypes.c_ulonglong _doCPoW(2**63, "") logger.info("Successfully tested C PoW DLL (cdecl) %s", bitmsglib) except: logger.error("C PoW test fail.", exc_info=True) bso = None else: try: bso = ctypes.CDLL(os.path.join(paths.codePath(), "bitmsghash", bitmsglib)) except OSError: import glob try: bso = ctypes.CDLL(glob.glob(os.path.join( paths.codePath(), "bitmsghash", "bitmsghash*.so" ))[0]) except (OSError, IndexError): bso = None except: bso = None else: logger.info("Loaded C PoW DLL %s", bitmsglib) if bso: try: bmpow = bso.BitmessagePOW bmpow.restype = ctypes.c_ulonglong except: bmpow = None else: bmpow = None if bmpow is None: buildCPoW()
def resetPoW(): openclpow.initCL()
def resetPoW(): """Initialise the OpenCL PoW""" openclpow.initCL()