diff --git a/WorkQueue.py b/WorkQueue.py index 10137cb..5dffc96 100644 --- a/WorkQueue.py +++ b/WorkQueue.py @@ -94,12 +94,12 @@ def storeWork(self, wu): work.base = 0 #check if there is a new block, if so reset queue - newBlock = (wu.data[4:36] != self.block) + newBlock = (wu.identifier != self.block) if newBlock: self.queue.clear() self.currentUnit = None self.lastBlock = self.block - self.block = wu.data[4:36] + self.block = wu.identifier self.logger.reportDebug("New block (WorkQueue)") #clear the idle flag since we just added work to queue diff --git a/kernels/phatk/__init__.py b/kernels/phatk/__init__.py index 018d80f..47c156e 100644 --- a/kernels/phatk/__init__.py +++ b/kernels/phatk/__init__.py @@ -210,7 +210,7 @@ def __init__(self, interface): try: self.loadKernel(self.device) except Exception: - self.interface.fatal("Failed to load OpenCL kernel!") + self.interface.fatal('Failed to load OpenCL kernel!') return # Initialize a command queue to send commands to the device, and a @@ -236,18 +236,18 @@ def loadKernel(self, device): # get the maximum worksize of the device maxWorkSize = self.device.get_info(cl.device_info.MAX_WORK_GROUP_SIZE) - # If the user didn't specify their own worksize, use the maximum supported worksize of the device + # If the user didn't specify their own worksize, + # use the maximum supported worksize of the device if self.WORKSIZE is None: - self.interface.error('WORKSIZE not supplied, using HW max. of ' + str(maxWorkSize)) + self.interface.debug('WORKSIZE not supplied, using HW max. of ' + + str(maxWorkSize)) self.WORKSIZE = maxWorkSize else: - # If the worksize is larger than the maximum supported worksize of the device + # If the worksize is larger than the maximum supported + # worksize of the device if (self.WORKSIZE > maxWorkSize): - self.interface.error('WORKSIZE out of range, using HW max. of ' + str(maxWorkSize)) - self.WORKSIZE = maxWorkSize - # If the worksize is not a power of 2 - if (self.WORKSIZE & (self.WORKSIZE - 1)) != 0: - self.interface.error('WORKSIZE invalid, using HW max. of ' + str(maxWorkSize)) + self.interface.error('WORKSIZE out of range, using HW max. of ' + + str(maxWorkSize)) self.WORKSIZE = maxWorkSize # These definitions are required for the kernel to function. @@ -304,7 +304,7 @@ def loadKernel(self, device): patcher = BFIPatcher(self.interface) binaryData = patcher.patch(self.kernel.binaries[0]) - self.interface.debug("Applied BFI_INT patch") + self.interface.debug('Applied BFI_INT patch') #reload the kernel with the patched binary self.kernel = cl.Program( @@ -321,7 +321,7 @@ def loadKernel(self, device): self.context, [device], [binaryData]).build(self.defines) except cl.LogicError: - self.interface.fatal("Failed to compile OpenCL kernel!") + self.interface.fatal('Failed to compile OpenCL kernel!') return except PatchError: self.interface.fatal('Failed to apply BFI_INT patch to kernel! ' diff --git a/kernels/phatk2/__init__.py b/kernels/phatk2/__init__.py index daf46df..71521c1 100644 --- a/kernels/phatk2/__init__.py +++ b/kernels/phatk2/__init__.py @@ -216,7 +216,7 @@ def __init__(self, interface): try: self.loadKernel(self.device) except Exception: - self.interface.fatal("Failed to load OpenCL kernel!") + self.interface.fatal('Failed to load OpenCL kernel!') return # Initialize a command queue to send commands to the device, and a @@ -242,18 +242,18 @@ def loadKernel(self, device): # get the maximum worksize of the device maxWorkSize = self.device.get_info(cl.device_info.MAX_WORK_GROUP_SIZE) - # If the user didn't specify their own worksize, use the maximum supported worksize of the device + # If the user didn't specify their own worksize, + # use the maximum supported worksize of the device if self.WORKSIZE is None: - self.interface.error('WORKSIZE not supplied, using HW max. of ' + str(maxWorkSize)) + self.interface.debug('WORKSIZE not supplied, using HW max. of ' + + str(maxWorkSize)) self.WORKSIZE = maxWorkSize else: - # If the worksize is larger than the maximum supported worksize of the device + # If the worksize is larger than the maximum supported + # worksize of the device if (self.WORKSIZE > maxWorkSize): - self.interface.error('WORKSIZE out of range, using HW max. of ' + str(maxWorkSize)) - self.WORKSIZE = maxWorkSize - # If the worksize is not a power of 2 - if (self.WORKSIZE & (self.WORKSIZE - 1)) != 0: - self.interface.error('WORKSIZE invalid, using HW max. of ' + str(maxWorkSize)) + self.interface.error('WORKSIZE out of range, using HW max. of ' + + str(maxWorkSize)) self.WORKSIZE = maxWorkSize # These definitions are required for the kernel to function. @@ -317,7 +317,7 @@ def loadKernel(self, device): patcher = BFIPatcher(self.interface) binaryData = patcher.patch(self.kernel.binaries[0]) - self.interface.debug("Applied BFI_INT patch") + self.interface.debug('Applied BFI_INT patch') #reload the kernel with the patched binary self.kernel = cl.Program( @@ -334,7 +334,7 @@ def loadKernel(self, device): self.context, [device], [binaryData]).build(self.defines) except cl.LogicError: - self.interface.fatal("Failed to compile OpenCL kernel!") + self.interface.fatal('Failed to compile OpenCL kernel!') return except PatchError: self.interface.fatal('Failed to apply BFI_INT patch to kernel! ' diff --git a/kernels/poclbm/__init__.py b/kernels/poclbm/__init__.py index 76ff84b..744035a 100644 --- a/kernels/poclbm/__init__.py +++ b/kernels/poclbm/__init__.py @@ -193,7 +193,7 @@ def __init__(self, interface): try: self.loadKernel(self.device) except Exception: - self.interface.fatal("Failed to load OpenCL kernel!") + self.interface.fatal('Failed to load OpenCL kernel!') return # Initialize a command queue to send commands to the device, and a @@ -219,18 +219,18 @@ def loadKernel(self, device): # get the maximum worksize of the device maxWorkSize = self.device.get_info(cl.device_info.MAX_WORK_GROUP_SIZE) - # If the user didn't specify their own worksize, use the maximum supported worksize of the device + # If the user didn't specify their own worksize, + # use the maximum supported worksize of the device if self.WORKSIZE is None: - self.interface.error('WORKSIZE not supplied, using HW max. of ' + str(maxWorkSize)) + self.interface.debug('WORKSIZE not supplied, using HW max. of ' + + str(maxWorkSize)) self.WORKSIZE = maxWorkSize else: - # If the worksize is larger than the maximum supported worksize of the device + # If the worksize is larger than the maximum supported + # worksize of the device if (self.WORKSIZE > maxWorkSize): - self.interface.error('WORKSIZE out of range, using HW max. of ' + str(maxWorkSize)) - self.WORKSIZE = maxWorkSize - # If the worksize is not a power of 2 - if (self.WORKSIZE & (self.WORKSIZE - 1)) != 0: - self.interface.error('WORKSIZE invalid, using HW max. of ' + str(maxWorkSize)) + self.interface.error('WORKSIZE out of range, using HW max. of ' + + str(maxWorkSize)) self.WORKSIZE = maxWorkSize # These definitions are required for the kernel to function. @@ -291,7 +291,7 @@ def loadKernel(self, device): patcher = BFIPatcher(self.interface) binaryData = patcher.patch(self.kernel.binaries[0]) - self.interface.debug("Applied BFI_INT patch") + self.interface.debug('Applied BFI_INT patch') #reload the kernel with the patched binary self.kernel = cl.Program( @@ -308,7 +308,7 @@ def loadKernel(self, device): self.context, [device], [binaryData]).build(self.defines) except cl.LogicError: - self.interface.fatal("Failed to compile OpenCL kernel!") + self.interface.fatal('Failed to compile OpenCL kernel!') return except PatchError: self.interface.fatal('Failed to apply BFI_INT patch to kernel! ' diff --git a/minerutil/ClientBase.py b/minerutil/ClientBase.py index c7c84f8..adfb549 100644 --- a/minerutil/ClientBase.py +++ b/minerutil/ClientBase.py @@ -27,6 +27,7 @@ class AssignedWork(object): target = None maxtime = None time = None + identifier = None def setMaxTimeIncrement(self, n): self.time = n self.maxtime = struct.unpack('>I', self.data[68:72])[0] + n diff --git a/minerutil/MMPProtocol.py b/minerutil/MMPProtocol.py index 49c4a2a..cd4467c 100644 --- a/minerutil/MMPProtocol.py +++ b/minerutil/MMPProtocol.py @@ -143,6 +143,7 @@ def cmd_WORK(self, work, mask): wu.mask = mask wu.target = self.target wu.setMaxTimeIncrement(self.time) + wu.identifier = data[4:36] self.runCallback('work', wu) # Since the server is giving work, we know it has accepted our # login details, so we can reset the factory's reconnect delay. diff --git a/minerutil/RPCProtocol.py b/minerutil/RPCProtocol.py index 1d10e85..c689e97 100644 --- a/minerutil/RPCProtocol.py +++ b/minerutil/RPCProtocol.py @@ -180,7 +180,8 @@ def call(self, method, params=[]): { 'Authorization': self.root.auth, 'User-Agent': self.root.version, - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + 'X-Work-Identifier': '1' }) (headers, data) = response @@ -206,10 +207,10 @@ class LongPoller(HTTPBase): callback function. """ - #Changed to 1800, since 600 seconds will cause it to reconnect + #Changed to 3600, since 600 seconds will cause it to reconnect #once every 10 minutes. Most pools will not cancel a long poll if the block - #exceeds 10 minutes. 30 minutes should be a sane value for this. - timeout = 1800 + #exceeds 10 minutes. 60 minutes should be a sane value for this. + timeout = 3600 def __init__(self, url, root): self.url = url @@ -235,7 +236,8 @@ def _request(self): None, { 'Authorization': self.root.auth, - 'User-Agent': self.root.version + 'User-Agent': self.root.version, + 'X-Work-Identifier': '1' }) d.addBoth(self._requestComplete) @@ -425,6 +427,7 @@ def handleWork(self, work, headers, pushed=False): aw.target = work['target'].decode('hex') aw.mask = work.get('mask', 32) aw.setMaxTimeIncrement(maxtime) + aw.identifier = work.get('identifier', aw.data[4:36]) if pushed: self.runCallback('push', aw) self.runCallback('work', aw)