示例#1
0
    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
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
 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
 def __init__(self, work: MiningWork, **kwargs):
     self.miner = QkchashMiner(work.difficulty, work.hash)