Exemple #1
0
        def __mine__():
            result, (header_hash, seed_hash, boundary) = mvs_rpc.eth_get_work()
            assert (result == 0)
            result, (height, difficulty) = mvs_rpc.get_info()
            assert (result == 0)

            rounds = 100
            nonce = 0
            while True:
                bin_nonce, mixhash = mine(block_number=height+1, difficulty=difficulty, mining_hash=header_hash,
                                          rounds=rounds, start_nonce=nonce)
                if bin_nonce:
                    break
                nonce += rounds
            return bin_nonce, '0x' + common.toString(header_hash), '0x' + common.toString(mixhash)
Exemple #2
0
    def mining(self, times=1):
        '''
        use the mainaddress to mining x times.
        do mining to get the main address rich.

        result, (height_origin, _) = mvs_rpc.get_info()
        assert (result == 0)
        mvs_rpc.start_mining(self.name, self.password, self.mainaddress(), times)
        for i in range(10):
            time.sleep(0.1)
            result, (height_new, _) = mvs_rpc.get_info()
            assert (result == 0)
            if height_new == (height_origin + times):
                break

        return
        '''
        from ethereum.pow.ethpow import mine
        result, message = mvs_rpc.set_miningaccount(self.name, self.password,
                                                    self.mainaddress())
        assert (result == 0)

        def __mine__():
            result, (header_hash, seed_hash, boundary) = mvs_rpc.eth_get_work()
            assert (result == 0)
            result, (height, difficulty) = mvs_rpc.get_info()
            assert (result == 0)

            rounds = 100
            nonce = 0
            while True:
                bin_nonce, mixhash = mine(block_number=height + 1,
                                          difficulty=difficulty,
                                          mining_hash=header_hash,
                                          rounds=rounds,
                                          start_nonce=nonce)
                if bin_nonce:
                    break
                nonce += rounds
            return bin_nonce, '0x' + common.toString(
                header_hash), '0x' + common.toString(mixhash)

        for i in xrange(times):
            bin_nonce, header_hash, mix_hash = __mine__()
            result, message = mvs_rpc.eth_submit_work(
                '0x' + common.toString(bin_nonce), header_hash, mix_hash)
            assert (result == 0)