checking in python3 progress...
This commit is contained in:
parent
83ccc9e39a
commit
7074a5d3df
|
@ -1,12 +1,12 @@
|
||||||
import Queue
|
from queue import Queue
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
class ObjectProcessorQueue(Queue.Queue):
|
class ObjectProcessorQueue(Queue):
|
||||||
maxSize = 32000000
|
maxSize = 32000000
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Queue.Queue.__init__(self)
|
Queue.__init__(self)
|
||||||
self.sizeLock = threading.Lock()
|
self.sizeLock = threading.Lock()
|
||||||
self.curSize = 0 # in Bytes. We maintain this to prevent nodes from flooing us with objects which take up too much memory. If this gets too big we'll sleep before asking for further objects.
|
self.curSize = 0 # in Bytes. We maintain this to prevent nodes from flooing us with objects which take up too much memory. If this gets too big we'll sleep before asking for further objects.
|
||||||
|
|
||||||
|
@ -15,10 +15,10 @@ class ObjectProcessorQueue(Queue.Queue):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
with self.sizeLock:
|
with self.sizeLock:
|
||||||
self.curSize += len(item[1])
|
self.curSize += len(item[1])
|
||||||
Queue.Queue.put(self, item, block, timeout)
|
Queue.put(self, item, block, timeout)
|
||||||
|
|
||||||
def get(self, block = True, timeout = None):
|
def get(self, block = True, timeout = None):
|
||||||
item = Queue.Queue.get(self, block, timeout)
|
item = Queue.get(self, block, timeout)
|
||||||
with self.sizeLock:
|
with self.sizeLock:
|
||||||
self.curSize -= len(item[1])
|
self.curSize -= len(item[1])
|
||||||
return item
|
return item
|
||||||
|
|
|
@ -4,7 +4,7 @@ from pyelliptic import arithmetic
|
||||||
# This function expects that pubkey begin with \x04
|
# This function expects that pubkey begin with \x04
|
||||||
def calculateBitcoinAddressFromPubkey(pubkey):
|
def calculateBitcoinAddressFromPubkey(pubkey):
|
||||||
if len(pubkey) != 65:
|
if len(pubkey) != 65:
|
||||||
print 'Could not calculate Bitcoin address from pubkey because function was passed a pubkey that was', len(pubkey), 'bytes long rather than 65.'
|
print('Could not calculate Bitcoin address from pubkey because function was passed a pubkey that was', len(pubkey), 'bytes long rather than 65.')
|
||||||
return "error"
|
return "error"
|
||||||
ripe = hashlib.new('ripemd160')
|
ripe = hashlib.new('ripemd160')
|
||||||
sha = hashlib.new('sha256')
|
sha = hashlib.new('sha256')
|
||||||
|
@ -25,7 +25,7 @@ def calculateBitcoinAddressFromPubkey(pubkey):
|
||||||
|
|
||||||
def calculateTestnetAddressFromPubkey(pubkey):
|
def calculateTestnetAddressFromPubkey(pubkey):
|
||||||
if len(pubkey) != 65:
|
if len(pubkey) != 65:
|
||||||
print 'Could not calculate Bitcoin address from pubkey because function was passed a pubkey that was', len(pubkey), 'bytes long rather than 65.'
|
print('Could not calculate Bitcoin address from pubkey because function was passed a pubkey that was', len(pubkey), 'bytes long rather than 65.')
|
||||||
return "error"
|
return "error"
|
||||||
ripe = hashlib.new('ripemd160')
|
ripe = hashlib.new('ripemd160')
|
||||||
sha = hashlib.new('sha256')
|
sha = hashlib.new('sha256')
|
||||||
|
|
|
@ -3,23 +3,10 @@
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
try:
|
|
||||||
import prctl
|
|
||||||
except ImportError:
|
|
||||||
def set_thread_name(name):
|
def set_thread_name(name):
|
||||||
"""Set the thread name for external use (visible from the OS)."""
|
"""Set the thread name for external use (visible from the OS)."""
|
||||||
threading.current_thread().name = name
|
threading.current_thread().name = name
|
||||||
else:
|
|
||||||
def set_thread_name(name):
|
|
||||||
"""Set a name for the thread for python internal use."""
|
|
||||||
prctl.set_name(name)
|
|
||||||
|
|
||||||
def _thread_name_hack(self):
|
|
||||||
set_thread_name(self.name)
|
|
||||||
threading.Thread.__bootstrap_original__(self)
|
|
||||||
|
|
||||||
threading.Thread.__bootstrap_original__ = threading.Thread._Thread__bootstrap
|
|
||||||
threading.Thread._Thread__bootstrap = _thread_name_hack
|
|
||||||
|
|
||||||
|
|
||||||
class StoppableThread(object):
|
class StoppableThread(object):
|
||||||
|
|
|
@ -8,7 +8,6 @@ from builtins import *
|
||||||
from builtins import object
|
from builtins import object
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from os import path, listdir
|
from os import path, listdir
|
||||||
from string import lower
|
|
||||||
|
|
||||||
from debug import logger
|
from debug import logger
|
||||||
import messagetypes
|
import messagetypes
|
||||||
|
@ -16,7 +15,7 @@ import paths
|
||||||
|
|
||||||
class MsgBase(object):
|
class MsgBase(object):
|
||||||
def encode(self):
|
def encode(self):
|
||||||
self.data = {"": lower(type(self).__name__)}
|
self.data = {"": type(self).__name__.lower()}
|
||||||
|
|
||||||
|
|
||||||
def constructObject(data):
|
def constructObject(data):
|
||||||
|
|
|
@ -3,13 +3,13 @@ src/multiqueue.py
|
||||||
=================
|
=================
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import Queue
|
from queue import Queue
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
import helper_random
|
import helper_random
|
||||||
|
|
||||||
|
|
||||||
class MultiQueue(Queue.Queue):
|
class MultiQueue(Queue):
|
||||||
"""A base queue class"""
|
"""A base queue class"""
|
||||||
# pylint: disable=redefined-builtin,attribute-defined-outside-init
|
# pylint: disable=redefined-builtin,attribute-defined-outside-init
|
||||||
defaultQueueCount = 10
|
defaultQueueCount = 10
|
||||||
|
@ -19,7 +19,7 @@ class MultiQueue(Queue.Queue):
|
||||||
self.queueCount = MultiQueue.defaultQueueCount
|
self.queueCount = MultiQueue.defaultQueueCount
|
||||||
else:
|
else:
|
||||||
self.queueCount = count
|
self.queueCount = count
|
||||||
Queue.Queue.__init__(self, maxsize)
|
Queue.__init__(self, maxsize)
|
||||||
|
|
||||||
# Initialize the queue representation
|
# Initialize the queue representation
|
||||||
def _init(self, maxsize):
|
def _init(self, maxsize):
|
||||||
|
|
|
@ -107,9 +107,9 @@ def do_opencl_pow(hash, target):
|
||||||
#initCL()
|
#initCL()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
target = 54227212183L
|
target = 54227212183
|
||||||
initialHash = "3758f55b5a8d902fd3597e4ce6a2d3f23daff735f65d9698c270987f4e67ad590b93f3ffeba0ef2fd08a8dc2f87b68ae5a0dc819ab57f22ad2c4c9c8618a43b3".decode("hex")
|
initialHash = "3758f55b5a8d902fd3597e4ce6a2d3f23daff735f65d9698c270987f4e67ad590b93f3ffeba0ef2fd08a8dc2f87b68ae5a0dc819ab57f22ad2c4c9c8618a43b3".decode("hex")
|
||||||
nonce = do_opencl_pow(initialHash.encode("hex"), target)
|
nonce = do_opencl_pow(initialHash.encode("hex"), target)
|
||||||
trialValue, = unpack('>Q',hashlib.sha512(hashlib.sha512(pack('>Q',nonce) + initialHash).digest()).digest()[0:8])
|
trialValue, = unpack('>Q',hashlib.sha512(hashlib.sha512(pack('>Q',nonce) + initialHash).digest()).digest()[0:8])
|
||||||
print "{} - value {} < {}".format(nonce, trialValue, target)
|
print("{} - value {} < {}".format(nonce, trialValue, target))
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import Queue
|
from queue import Queue
|
||||||
|
|
||||||
from class_objectProcessorQueue import ObjectProcessorQueue
|
from class_objectProcessorQueue import ObjectProcessorQueue
|
||||||
from multiqueue import MultiQueue
|
from multiqueue import MultiQueue
|
||||||
|
|
||||||
workerQueue = Queue.Queue()
|
workerQueue = Queue()
|
||||||
UISignalQueue = Queue.Queue()
|
UISignalQueue = Queue()
|
||||||
addressGeneratorQueue = Queue.Queue()
|
addressGeneratorQueue = Queue()
|
||||||
# receiveDataThreads dump objects they hear on the network into this
|
# receiveDataThreads dump objects they hear on the network into this
|
||||||
# queue to be processed.
|
# queue to be processed.
|
||||||
objectProcessorQueue = ObjectProcessorQueue()
|
objectProcessorQueue = ObjectProcessorQueue()
|
||||||
invQueue = MultiQueue()
|
invQueue = MultiQueue()
|
||||||
addrQueue = MultiQueue()
|
addrQueue = MultiQueue()
|
||||||
portCheckerQueue = Queue.Queue()
|
portCheckerQueue = Queue()
|
||||||
receiveDataQueue = Queue.Queue()
|
receiveDataQueue = Queue()
|
||||||
# The address generator thread uses this queue to get information back
|
# The address generator thread uses this queue to get information back
|
||||||
# to the API thread.
|
# to the API thread.
|
||||||
apiAddressGeneratorReturnQueue = Queue.Queue()
|
apiAddressGeneratorReturnQueue = Queue()
|
||||||
# Exceptions
|
# Exceptions
|
||||||
excQueue = Queue.Queue()
|
excQueue = Queue()
|
||||||
|
|
|
@ -140,20 +140,20 @@ if __name__ == '__main__':
|
||||||
k = RandomTrackingDict()
|
k = RandomTrackingDict()
|
||||||
d = {}
|
d = {}
|
||||||
|
|
||||||
print "populating random tracking dict"
|
print("populating random tracking dict")
|
||||||
a.append(time())
|
a.append(time())
|
||||||
for i in range(50000):
|
for i in range(50000):
|
||||||
k[randString()] = True
|
k[randString()] = True
|
||||||
a.append(time())
|
a.append(time())
|
||||||
print "done"
|
print("done")
|
||||||
|
|
||||||
while k:
|
while k:
|
||||||
retval = k.randomKeys(1000)
|
retval = k.randomKeys(1000)
|
||||||
if not retval:
|
if not retval:
|
||||||
print "error getting random keys"
|
print("error getting random keys")
|
||||||
try:
|
try:
|
||||||
k.randomKeys(100)
|
k.randomKeys(100)
|
||||||
print "bad"
|
print("bad")
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
for i in retval:
|
for i in retval:
|
||||||
|
@ -161,4 +161,4 @@ if __name__ == '__main__':
|
||||||
a.append(time())
|
a.append(time())
|
||||||
|
|
||||||
for x in range(len(a) - 1):
|
for x in range(len(a) - 1):
|
||||||
print "%i: %.3f" % (x, a[x + 1] - a[x])
|
print("%i: %.3f" % (x, a[x + 1] - a[x]))
|
||||||
|
|
|
@ -25,8 +25,8 @@ def translateText(context, text, n = None):
|
||||||
try:
|
try:
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
except Exception as err:
|
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('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
|
print('Error message:', err)
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
if n is None:
|
if n is None:
|
||||||
return QtGui.QApplication.translate(context, text)
|
return QtGui.QApplication.translate(context, text)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user