コード例 #1
0
ファイル: blocks.py プロジェクト: Feretrius/pyethereum
    def check_pow(self, nonce=None):
        """Check if the proof-of-work of the block is valid.

        :param nonce: if given the proof of work function will be evaluated
                      with this nonce instead of the one already present in
                      the header
        :returns: `True` or `False`
        """
        log.debug('checking pow', block=self.hex_hash()[:8])
        return check_pow(self.number, self.mining_hash, self.mixhash, nonce or self.nonce,
                         self.difficulty)
def worker():
    while True:
        item = q.get()
        try:
            block_number = int(jsonArrayElements[int(item)]['block'])
            difficulty = int(jsonArrayElements[int(item)]['diff'])
            header_hash = decode_hex(jsonArrayElements[int(item)]['pow'])
            mixhash = decode_hex(jsonArrayElements[int(item)]['digest'])
            nonce = decode_hex(jsonArrayElements[int(item)]['nonce'])
            result = ethpow.check_pow(block_number, header_hash, mixhash, nonce, difficulty)
            print 'I:'+str(item)+' Nonce:'+ encode_hex(nonce)+'='+str(result)
        finally:
            q.task_done()
コード例 #3
0
def worker():
    while True:
        item = q.get()
        try:
            block_number = int(jsonArrayElements[int(item)]['block'])
            difficulty = int(jsonArrayElements[int(item)]['diff'])
            header_hash = decode_hex(jsonArrayElements[int(item)]['pow'])
            mixhash = decode_hex(jsonArrayElements[int(item)]['digest'])
            nonce = decode_hex(jsonArrayElements[int(item)]['nonce'])
            result = ethpow.check_pow(block_number, header_hash, mixhash,
                                      nonce, difficulty)
            print 'I:' + str(item) + ' Nonce:' + encode_hex(nonce) + '=' + str(
                result)
        finally:
            q.task_done()
import sys
import ethpow
import math
import utils
from rlp.sedes import big_endian_int, BigEndianInt, Binary
from rlp.utils import decode_hex, encode_hex, ascii_chr, str_to_bytes



block_number = int(sys.argv[1]);
difficulty = int(sys.argv[5]);
header_hash = decode_hex(sys.argv[2])
mixhash = decode_hex(sys.argv[3])
nonce = decode_hex(sys.argv[4])



#print "\nBlock_Number:",block_number
#print "\nHeader_hash:"+header_hash
#print "\nMixhash:"+mixhash
#print "\nNonce:"+nonce
#print "\nDiff:",difficulty


#check_pow(block_number, header_hash, mixhash, nonce, difficulty):

print ethpow.check_pow(block_number, header_hash, mixhash, nonce, difficulty)