コード例 #1
0
ファイル: test_qkcpow.py プロジェクト: zrthxn/pyquarkchain
    def test_pow(self):
        header = (2**256 - 1234567890).to_bytes(32, "big")
        diff = 10
        miner = QkchashMiner(diff, header)
        nonce, mixhash = miner.mine()
        self.assertIsNotNone(nonce)
        self.assertIsNotNone(mixhash)

        # wrong nonce, mixhash order
        self.assertFalse(check_pow(header, nonce, mixhash, diff))

        self.assertTrue(check_pow(header, mixhash, nonce, diff))
コード例 #2
0
ファイル: miner.py プロジェクト: zrthxn/pyquarkchain
class Qkchash(MiningAlgorithm):
    def __init__(self, work: MiningWork, **kwargs):
        self.miner = QkchashMiner(work.difficulty, work.hash)

    def mine(self, start_nonce: int, end_nonce: int) -> Optional[MiningResult]:
        nonce_found, mixhash = self.miner.mine(rounds=end_nonce - start_nonce,
                                               start_nonce=start_nonce)
        if not nonce_found:
            return None
        return MiningResult(
            self.miner.header_hash,
            int.from_bytes(nonce_found, byteorder="big"),
            mixhash,
        )
コード例 #3
0
ファイル: miner.py プロジェクト: twelveze/pyquarkchain
 def __init__(self, work: MiningWork, **kwargs):
     qkchash_with_rotation_stats = kwargs.get("qkchash_with_rotation_stats",
                                              False)
     self.miner = QkchashMiner(work.height, work.difficulty, work.hash,
                               qkchash_with_rotation_stats)
コード例 #4
0
ファイル: miner.py プロジェクト: zrthxn/pyquarkchain
 def __init__(self, work: MiningWork, **kwargs):
     self.miner = QkchashMiner(work.difficulty, work.hash)