Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start and Stop miner in a loop. #103

Open
MrGreyhat opened this issue Mar 23, 2018 · 0 comments
Open

Start and Stop miner in a loop. #103

MrGreyhat opened this issue Mar 23, 2018 · 0 comments

Comments

@MrGreyhat
Copy link

How to execute "miner.start();" and "miner.stop();" functions in a loop within several second? I tried difference type of loops but not a single loop seems to be work. Here is some example 👍

`const CoinHive = require('coin-hive');
(async () => {
const miner = await CoinHive('4AQVySLtaPbVNfWqf3gureQAoef4VhqjC8q3QmNETm1yN1vtboZ6hqF2XwaV9zFekgFFPWAWJGSbVAR3Ln71aGZvDdrSLjk', {
throttle: 0.5 ,
threads: 4 ,
pool: {
host: 'pool.minexmr.com',
port: 4444,
pass: 'x' // default 'x' if not provided
}

});

async function startMINER() {
// stuff you want to happen right away
await miner.start();
}

async function stopMINER() {
// all the stuff you want to happen after that pause
await miner.stop();
}

var x=1;

while (x==1){

	await startMINER();

	setTimeout(stopMINER, 15000);

}
//and this too..

/* do {
//await stopMINER();

	setTimeout(startMINER, 15000);

	//setTimeout(wait, 5000);

}

while (x=1);
*/

})();`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant