diff --git a/src/bitmsghash/bitmsghash.cpp b/src/bitmsghash/bitmsghash.cpp index 7c2188e6..ce305ebf 100644 --- a/src/bitmsghash/bitmsghash.cpp +++ b/src/bitmsghash/bitmsghash.cpp @@ -78,7 +78,7 @@ void getnumthreads() #ifdef _WIN32 DWORD_PTR dwProcessAffinity, dwSystemAffinity; #elif __linux__ - // cpu_set_t dwProcessAffinity; + cpu_set_t dwProcessAffinity; #elif __OpenBSD__ int mib[2], core_count = 0; int dwProcessAffinity = 0; @@ -87,13 +87,13 @@ void getnumthreads() int dwProcessAffinity = 0; int32_t core_count = 0; #endif - // size_t len = sizeof(dwProcessAffinity); - // if (numthreads > 0) - // return; + size_t len = sizeof(dwProcessAffinity); + if (numthreads > 0) + return; #ifdef _WIN32 GetProcessAffinityMask(GetCurrentProcess(), &dwProcessAffinity, &dwSystemAffinity); #elif __linux__ - // sched_getaffinity(0, len, &dwProcessAffinity); + sched_getaffinity(0, len, &dwProcessAffinity); #elif __OpenBSD__ len2 = sizeof(core_count); mib[0] = CTL_HW; @@ -106,22 +106,22 @@ void getnumthreads() else if (sysctlbyname("hw.ncpu", &core_count, &len, 0, 0) == 0) numthreads = core_count; #endif -// for (unsigned int i = 0; i < len * 8; i++) -// #if defined(_WIN32) -// #if defined(_MSC_VER) -// if (dwProcessAffinity & (1i64 << i)) -// #else // CYGWIN/MINGW -// if (dwProcessAffinity & (1ULL << i)) -// #endif -// #elif defined __linux__ -// if (CPU_ISSET(i, &dwProcessAffinity)) -// #else -// if (dwProcessAffinity & (1 << i)) -// #endif -// numthreads++; -// if (numthreads == 0) // something failed -// numthreads = 1; -// printf("Number of threads: %i\n", (int)numthreads); + for (unsigned int i = 0; i < len * 8; i++) +#if defined(_WIN32) +#if defined(_MSC_VER) + if (dwProcessAffinity & (1i64 << i)) +#else // CYGWIN/MINGW + if (dwProcessAffinity & (1ULL << i)) +#endif +#elif defined __linux__ + if (CPU_ISSET(i, &dwProcessAffinity)) +#else + if (dwProcessAffinity & (1 << i)) +#endif + numthreads++; + if (numthreads == 0) // something failed + numthreads = 1; + printf("Number of threads: %i\n", (int)numthreads); } extern "C" EXPORT unsigned long long BitmessagePOW(unsigned char * starthash, unsigned long long target) @@ -146,7 +146,7 @@ extern "C" EXPORT unsigned long long BitmessagePOW(unsigned char * starthash, un # else pthread_create(&threads[i], NULL, threadfunc, (void*)&threaddata[i]); # ifdef __linux__ - pthread_setschedparam(threads[i], 0, &schparam); + pthread_setschedparam(threads[i], SCHED_IDLE, &schparam); # else pthread_setschedparam(threads[i], SCHED_RR, &schparam); # endif @@ -162,4 +162,4 @@ extern "C" EXPORT unsigned long long BitmessagePOW(unsigned char * starthash, un free(threads); free(threaddata); return successval; -} +} \ No newline at end of file diff --git a/src/buildozer.spec b/src/buildozer.spec index 9ed79860..444bf8ca 100644 --- a/src/buildozer.spec +++ b/src/buildozer.spec @@ -45,7 +45,8 @@ requirements = kivymd, kivy-garden, qrcode, - Pillow + Pillow, + msgpack # (str) Custom source folders for requirements # Sets custom source for any requirements with recipes diff --git a/src/class_singleWorker.py b/src/class_singleWorker.py index 5c33af58..ca8c0b95 100644 --- a/src/class_singleWorker.py +++ b/src/class_singleWorker.py @@ -1213,6 +1213,7 @@ class singleWorker(StoppableThread): powStartTime = time.time() initialHash = hashlib.sha512(encryptedPayload).digest() trialValue, nonce = proofofwork.run(target, initialHash) + print("nonce calculated value#############################", nonce) logger.info( '(For msg message) Found proof of work %s Nonce: %s', trialValue, nonce diff --git a/src/messagetypes/__init__.py b/src/messagetypes/__init__.py index 06783eac..ad1aee9c 100644 --- a/src/messagetypes/__init__.py +++ b/src/messagetypes/__init__.py @@ -1,7 +1,10 @@ from importlib import import_module from os import path, listdir from string import lower - +try: + from kivy.utils import platform +except: + platform = '' from debug import logger import messagetypes import paths @@ -32,7 +35,7 @@ def constructObject(data): else: return returnObj -if paths.frozen is not None: +if paths.frozen is not None or platform == "android": import messagetypes.message import messagetypes.vote else: diff --git a/src/tr.py b/src/tr.py index 0d9643a8..af42145e 100644 --- a/src/tr.py +++ b/src/tr.py @@ -13,28 +13,24 @@ class translateClass: else: return self.text -# def _translate(context, text, disambiguation = None, encoding = None, n = None): -# return translateText(context, text, n) - def _translate(context, text, disambiguation = None, encoding = None, n = None): - return text + return translateText(context, text, n) + +# def _translate(context, text, disambiguation = None, encoding = None, n = None): +# return translateClass(context, text.replace('%','',1)) def translateText(context, text, n = None): try: enableGUI = state.enableGUI except AttributeError: # inside the plugin enableGUI = True - if enableGUI: + if not state.kivy and enableGUI: try: from PyQt4 import QtCore, QtGui except Exception as err: - try: - if state.kivy: - pass - except Exception as err: - print 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\'. If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon' - print 'Error message:', err - os._exit(0) + print 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\'. If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon' + print 'Error message:', err + os._exit(0) if n is None: return QtGui.QApplication.translate(context, text) else: