-
-
Notifications
You must be signed in to change notification settings - Fork 1
3. Miner usage
const miner = new Duco({
username: 'axorax'
});
miner.start();
const miner = new Duco({
username: 'axorax',
threads: 1,
rigid: 'duco-js-miner',
key: 'mySecretKey',
id: 'my-cool-miner'
});
threads, rigid, id and key are optional but username is required. If no username is provided, then the created miner will have username set to 'axorax' by default. This will make the miner mine for the user named axorax.
Type | Argument | Description |
---|---|---|
required | username | Person who the miner will mine for |
optional | threads | Amount of threads that should be used |
optional | rigid | Gives the miner an id that appears in your miner list |
optional | key | Only needed if you have an active key |
optional | id | Gives the miner a HTML id tag |
The default values are:
Argument | Default value |
---|---|
username | 'axorax' |
threads | 1 |
rigid | 'duco.js' |
key | '' |
id | <randomly-generated> |
The bare minimum to create a miner is:
const miner = new Duco({
username: 'axorax'
});
We recommend not using this and just leaving threads to 1
.
const miner = new Duco({
username: 'axorax',
threads: 'max'
});
miner.start();
miner.startAfter(5000);
The time must be passed in milliseconds. In the above example, it will start the miner after 5 seconds (5000ms = 5s)
miner.stop();
miner.stopAfter(5000);
miner.delete();
This will stop the miner. Unlike miner.stop();
it will not update any variables. It will only stop the miner and won't update any variables like miner.running
and miner.stoppedTimestamp
miner.deleteAfter(5000);
miner.change({
username: 'changed_username',
threads: 2,
rigid: 'myCoolMiner',
key: 'superSecret'
});
After changing the miner, it will not start automatically.
miner.change({
username: 'changed_username',
threads: 2,
rigid: 'myCoolMiner',
key: 'superSecret',
start: true
});
Set the value of start
to true to make the miner start automatically after being changed.
miner.changeAfter({
username: 'changed_username',
threads: 2,
rigid: 'myCoolMiner',
key: 'superSecret'
}, 5000);
This works similar to miner.change()
but you need to also provide a time in milliseconds after the curly braces {}
. In the given example, the miner will get changed after 5 seconds (5000ms = 5s)
miner.onRemove(() => {
console.log('Miner was removed!')
});
If the user removes the miner from the DOM by using inspect element, running JavaScript code or anything else then the code inside will be executed.
Alternative ways to use miner.onRemove()
:
miner.onRemove(removedFunction);
function removedFunction() {
console.log('Removed Miner!')
};
miner.onRemove(function() {
console.log('Removed Miner!')
});
miner.onRemoveCreateNew();
If the user removes the miner from the DOM then it will create a new miner with all the settings specified in the original miner before. If the user again removes the newly created miner then it will again create another miner.
You can use both miner.onRemove();
and miner.onRemoveCreateNew();
without any trouble. For example:
miner.onRemoveCreateNew();
miner.onRemove(() => {
console.log('Miner was removed!')
});
let minerUsername = miner.username;
let minerThreads = miner.threads;
let minerId = miner.id;
// you can get all values like that
miner.createdTimestamp
miner.startedTimestamp
miner.stoppedTimestamp
miner.running
miner.changed
miner.addStyle(`
display: block;
width: 500px:
height: 400px;
`);