Пример #1
0
def masterMiner():
	miners_started = 0
	challenge,apiId,difficulty,apiString,granularity = getVariables();
	while True:
		nonce = mine(str(challenge),public_keys[miners_started],difficulty);
		if(nonce > 0):
			value = max(0,(5000- miners_started*10) * granularity);
			#value = max(0,(getAPIvalue(apiString) - miners_started*10) * granularity); #account 2 should always be winner
			arg_string =""+ str(nonce) + " "+ str(apiId) +" " + str(value)+" "+str(contract_address)+" "+str(public_keys[miners_started])+" "+str(private_keys[miners_started])
			print('Arg String', arg_string)
			#success = execute_js('testSubmitter.js',arg_string)
			#print('WE WERE SUCCESSFUL: ', success)
			run_js('testSubmitter.js',arg_string);
			miners_started += 1 
			if(miners_started == 5):
				v = False;
				while(v == False):
					time.sleep(2);
					_challenge,_apiId,_difficulty,_apiString,_granularity= getVariables();
					if challenge == _challenge:
						v = False
						time.sleep(10);
					elif _apiId > 0:
						v = True
						challenge = _challenge;
						apiId = _apiId;
						difficulty = _difficulty;
						apiString = _apiString;
						granularity = _granularity;
				miners_started = 0;
		else:
			challenge,apiId,difficulty,apiString = getVariables(); 
			print('variables grabbed')
	print('Miner Stopping')
Пример #2
0
def masterMiner():
    while True:
        challenge, difficulty = getVariables()
        print(challenge, difficulty)
        nonce = mine(challenge, public_address[2:], difficulty)
        print(nonce)
        if (nonce > 0):
            print("You guessed the hash")
            value = getAPIvalue()
            arg_string = "" + str(nonce) + " " + str(value) + " " + str(
                contract_address) + " " + str(public_address)
            run_js('submitter.js', arg_string)
            time.sleep(30)
        else:
            pass
def startExit():
    global contract_address
    contract_address = getAddress()
    while True:
        _utxoPos = createSignature()
        arg_string = "" + str(_utxoPos) + " " + str(NULL_ADDRESS) + " " + str(
            1e18) + " " + str(contract_address) + " " + str(
                public_keys[1]) + " " + str(private_keys[1])
        run_js('submitter.js', arg_string)
        print("whithdrawal submitted")
        break
        new_address = getAddress()
        if (contract_address != new_address):
            contract_address = new_address
        else:
            block = getPlasmaBlock()
    print('Stopping Tests')
Пример #4
0
    def execute(self):
        """
        Executes the action_block in the PinFile
        """

        for action in self.action_data["actions"]:
            context = self.action_data.get("context", True)
            path = self.action_data["path"]
            file_path = "{0}/{1}".format(path, action)
            command = self.add_ctx_params(file_path, context)
            success = run_js(command)
            return success
Пример #5
0
def masterMiner():
    miners_started = 0
    challenge, apiId, difficulty, apiString = getVariables()
    while True:
        nonce = mine(str(challenge), public_keys[miners_started], difficulty)
        print('n', nonce)
        if (nonce > 0):
            print("You guessed the hash!")
            value = max(0,
                        getAPIvalue(apiString) - miners_started * 10)
            #account 2 should always be winner
            arg_string = "" + str(nonce) + " " + str(apiId) + " " + str(
                value) + " " + str(contract_address) + " " + str(
                    public_keys[miners_started]) + " " + str(
                        private_keys[miners_started])
            print(arg_string)
            #success = execute_js('testSubmitter.js',arg_string)
            #print('WE WERE SUCCESSFUL: ', success)
            run_js('testSubmitter.js', arg_string)
            miners_started += 1
            if (miners_started == 5):
                v = False
                while (v == False):
                    time.sleep(2)
                    _challenge, _apiId, _difficulty, _apiString = getVariables(
                    )
                    if challenge == _challenge:
                        v = False
                        time.sleep(10)
                    elif _apiId > 0:
                        v = True
                        challenge = _challenge
                        apiId = _apiId
                        difficulty = _difficulty
                        apiString = _apiString
                miners_started = 0
        else:
            challenge, apiId, difficulty, apiString = getVariables()
    print('Miner Stopping')
    def execute(self):

        """
        Executes the action_block in the PinFile
        """

        for action in self.action_data["actions"]:
            context = self.action_data.get("context", True)
            path = self.action_data["path"]
            file_path = "{0}/{1}".format(path, action)
            command = self.add_ctx_params(file_path, context)
            success = run_js(command)
            return success
Пример #7
0
def masterMiner():
    miners_started = 0
    getAddress()
    challenge, difficulty = getVariables()
    while True:
        nonce = mine(str(challenge), public_keys[miners_started], difficulty)
        if (nonce > 0):
            print("You guessed the hash!")
            value = getAPIvalue() - miners_started * 10
            #account 2 should always be winner
            arg_string = "" + str(nonce) + " " + str(value) + " " + str(
                contract_address) + " " + str(
                    public_keys[miners_started]) + " " + str(
                        private_keys[miners_started])
            run_js('submitter.js', arg_string)
            miners_started += 1
            if (miners_started == 5):
                getAddress()
                challenge, difficulty = getVariables()
                miners_started = 0
        else:
            pass
    print('Miner Stopping')
Пример #8
0
def masterMiner():
    miners_started = 0
    while True:
        nonce = mine(str(challenge), public_keys[miners_started], difficulty)
        print('n', nonce)
        if (nonce > 0):
            print("You guessed the hash!")
            value = max(0, (5000 - miners_started * 10) * granularity)
            #value = max(0,(getAPIvalue(apiString) - miners_started*10) * granularity); #account 2 should always be winner
            arg_string = "" + str(nonce) + " " + str(apiId) + " " + str(
                value) + " " + str(contract_address) + " " + str(
                    public_keys[miners_started]) + " " + str(
                        private_keys[miners_started])
            print(arg_string)
            #success = execute_js('testSubmitter.js',arg_string)
            #print('WE WERE SUCCESSFUL: ', success)
            run_js('rinkebySubmitter.js', arg_string)
            miners_started += 1
            if (miners_started == 5):
                break
        else:
            break
    print('Miner Stopping')
Пример #9
0
def clearNonce():
	arg_string =""+ str(nonce) + " "+str(private_key)+" "+str(gasPrice)+" "+str(public_address)
	run_js('submitter.js',arg_string);
Пример #10
0
 def test_run_rb_success_suppress_exitstatus_false(self):
     out = run_js(self.node_success_path, suppress_exit_status_call=False
                  )  # when command succeeds SystemExit is not raised
     self.assertEqual(b'success\n', out)
Пример #11
0
 def test_run_node_fail_suppress_exitstatus_false(self):
     with self.assertRaises(SystemExit):
         out = run_js(
             self.node_fail_path, suppress_exit_status_call=False
         )  # when suppress_exit_status=True, Python script stopped prematurely
Пример #12
0
 def test_run_node_fail_suppress_stderr(self):
     out = run_js(self.node_fail_path, suppress_stderr=True)
     self.assertEqual(False, out)  # returns False
Пример #13
0
 def test_run_node_success_suppress_stdout(self):
     out = run_js(self.node_success_path, suppress_stdout=True)
     self.assertEqual(
         b'success\n',
         out)  # still returns a value, does not print to std out
Пример #14
0
 def test_run_node_success(self):
     out = run_js(self.node_success_path)
     self.assertEqual(b'success\n', out)
Пример #15
0
 def test_run_rb_success_suppress_exitstatus_false(self):
     out = run_js(self.node_success_path, suppress_exit_status_call=False) # when command succeeds SystemExit is not raised
     self.assertEqual(b'success\n', out)
Пример #16
0
 def test_run_node_fail_suppress_exitstatus_false(self):
     with self.assertRaises(SystemExit):
         out = run_js(self.node_fail_path, suppress_exit_status_call=False) # when suppress_exit_status=True, Python script stopped prematurely
Пример #17
0
 def test_run_node_fail_suppress_stderr(self):
     out = run_js(self.node_fail_path, suppress_stderr=True)
     self.assertEqual(False, out)  # returns False
Пример #18
0
 def test_run_node_success_suppress_stdout(self):
     out = run_js(self.node_success_path, suppress_stdout=True)
     self.assertEqual(b'success\n', out) # still returns a value, does not print to std out
Пример #19
0
 def test_run_node_success(self):
     out = run_js(self.node_success_path)
     self.assertEqual(b'success\n', out)