Exemplo n.º 1
0
	def send(self, result, send_callback):
		for nonce in result.miner.nonce_generator(result.nonces):

			h = hash(result.state, result.merkle_end, result.time, result.difficulty, nonce)

			if h[7] != 0:
				hash6 = pack('<I', long(h[6])).encode('hex')
				say_line('Verification failed, check hardware! (%s, %s)', (result.miner.id(), hash6))
				return True # consume this particular result
			else:
				self.diff1_found(bytereverse(h[6]), result.target[6])
				if belowOrEquals(h[:7], result.target[:7]):
					is_block = belowOrEquals(h[:7], self.true_target[:7])

					hash6 = pack('<I', long(h[6])).encode('hex')
					hash5 = pack('<I', long(h[5])).encode('hex')
					self.sent[nonce] = (is_block, hash6, hash5)
					ntime = long(pack('<I', long(result.time)).encode('hex'),16)
					resnonce = long(pack('<I', long(nonce)).encode('hex'),16)
					block = self.source.create_block_header(self.source.merkle_root, ntime, self.source.bits, resnonce)
					hash_header = hashlib.sha256(hashlib.sha256(block).digest()).digest()[::-1]
					shouldSend = int(hash_header.encode('hex_codec'), 16) < self.source.server_difficulty
					print "t->" + str(ntime) + " nonce->" + str(resnonce) + " shouldSend->" + str(shouldSend)
					if shouldSend:
						if not send_callback(result, nonce):
							return False

		return True
Exemplo n.º 2
0
	def send(self, result, send_callback):
		for nonce in result.miner.nonce_generator(result.nonces):
			h = hash(result.state, result.merkle_end, result.time, result.difficulty, nonce)
			if h[7] != 0:
				hash6 = pack('I', long(h[6])).encode('hex')
				say_line('Verification failed, check hardware! (%s, %s)', (result.miner.id(), hash6))
				return True # consume this particular result
			else:
				self.diff1_found(bytereverse(h[6]), result.target[6])
				if belowOrEquals(h[:7], result.target[:7]):
					is_block = belowOrEquals(h[:7], self.true_target[:7])
					hash6 = pack('I', long(h[6])).encode('hex')
					hash5 = pack('I', long(h[5])).encode('hex')
					self.sent[nonce] = (is_block, hash6, hash5)
					if not send_callback(result, nonce):
						return False
		return True
Exemplo n.º 3
0
	def send(self, result, send_callback):
		for nonce in result.miner.nonce_generator(result.nonces):
			h = hash(result.state, result.merkle_end, result.time, result.difficulty, nonce)
			if h[7] != 0:
				hash6 = pack('I', long(h[6])).encode('hex')
				say_line('Verification failed, check hardware! (%s, %s)', (result.miner.id(), hash6))
				return True # consume this particular result
			else:
				self.diff1_found(bytereverse(h[6]), result.target[6])
				if belowOrEquals(h[:7], result.target[:7]):
					is_block = belowOrEquals(h[:7], self.true_target[:7])
					hash6 = pack('I', long(h[6])).encode('hex')
					hash5 = pack('I', long(h[5])).encode('hex')
					self.sent[nonce] = (is_block, hash6, hash5)
					if not send_callback(result, nonce):
						return False
		return True
Exemplo n.º 4
0
 def send(self, result, send_callback):
     for nonce in result.miner.nonce_generator(result.nonces):
         # h = hash(result.state, result.merkle_end, result.time, result.difficulty, nonce)
         hx = ''.join(pack('>19I', *result.dataX))
         qh = skeinhash(''.join([hx, pack('>I', long(nonce))]))
         h = unpack('>8I', qh)
         #if h[6] & 0xf == 0:
         #    say_line('Nonce: %08x, hash: %s, h6: %08x', (nonce, qh.encode('hex'), h[6]))
         if qh[-3:] != '\x00\x00\x00':
             hash7 = pack('<I', long(h[7])).encode('hex')
             say_line('Verification failed, check hardware! (%s, %s, %08x)', (result.miner.id(), hash7, nonce))
             say_line('data %s' % ''.join([hx, pack('>I', long(nonce))]).encode('hex'))
             return True # consume this particular result
         else:
             self.diff1_found(bytereverse(h[6]), result.target[6])
             if belowOrEquals(h[:7], result.target[:7]):
                 is_block = belowOrEquals(h[:7], self.true_target[:7])
                 hash6 = pack('<I', long(h[6])).encode('hex')
                 hash5 = pack('<I', long(h[5])).encode('hex')
                 self.sent[nonce] = (is_block, hash6, hash5)
                 if not send_callback(result, nonce):
                     return False
     return True