Crypto-Loot / cryptoloot

Self Hosted Library for CryptoLoot
https://crypto-loot.com
55 stars 16 forks source link

setNumThreads not working #5

Closed cedriking closed 5 years ago

cedriking commented 6 years ago

Hello :smiley: I'm trying to make the user to set the number of threads manually with a custom UI I built but it's not working.

This is my simple code I have right now:

var maxThreads = window.navigator.hardwareConcurrency;
var threads = maxThreads / 2;
if (maxThreads < 1) {
    maxThreads = 1;
}
if (threads < 1) {
    maxThreads = 1;
}

var miner = new CRLT.User('CODE', username, {
            threads: threads,
            autoThreads: false,
            throttle: 0.2
        });

Later on the same file I have a function:

function setNumThreads() {
    $('.js-current-threads').text(threads);
    if (miner) {
        miner.setNumThreads(threads);
    }
}

When I set the number of threads nothing changes, I also tried to do it manually calling miner.setNumThreads(1); on the console and nothing. Number of workers are always the same too on the dev tools.

I also noticed that miner.isRunning() also say false, always, even while running.

I think these functions are broken.

Thank you.

denniske commented 5 years ago

Same for me. setNumThreads and setThrottle not working.

Can you fix this?

cedriking commented 5 years ago

Hey @denniske , The solution I found for that client was to stop the miner, initialize my miner variable again with the new amount, then start it.

Hope it helps :)

denniske commented 5 years ago

Thank you. That 's a good idea. I will try that :)