Constructor
new CPUMiner(miner)
Create a CPU miner.
Parameters:
Name | Type | Description |
---|---|---|
miner |
Miner |
- Source:
Members
(static, constant) INTERVAL :Number
Nonce range interval.
Type:
- Number
- Source:
Methods
(async, private) _start() → {Promise}
Start mining.
- Source:
Returns:
- Type
- Promise
(async) _stop() → {Promise}
Stop mining (without a lock).
- Source:
Returns:
- Type
- Promise
(async) close() → {Promise}
Close the miner.
- Source:
Returns:
- Type
- Promise
(async) createJob(tipnullable, addressnullable) → {Promise}
Create a mining job.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tip |
ChainEntry |
<nullable> |
|
address |
Address |
<nullable> |
- Source:
Returns:
- Returns Job.
- Type
- Promise
findNonce(job) → {Number}
Hash until the nonce overflows.
Parameters:
Name | Type | Description |
---|---|---|
job |
CPUJob |
- Source:
Returns:
nonce
- Type
- Number
(async) findNonceAsync(job) → {Promise}
Hash until the nonce overflows.
Parameters:
Name | Type | Description |
---|---|---|
job |
CPUJob |
- Source:
Returns:
Returns Number.
- Type
- Promise
(private) init()
Initialize the miner.
- Source:
mine(job) → {Block}
Mine synchronously until the block is found.
Parameters:
Name | Type | Description |
---|---|---|
job |
CPUJob |
- Source:
Returns:
- Type
- Block
(async) mineAsync(job) → {Promise}
Mine asynchronously until the block is found.
Parameters:
Name | Type | Description |
---|---|---|
job |
CPUJob |
- Source:
Returns:
- Returns Block.
- Type
- Promise
(async) mineBlock(tipnullable, addressnullable) → {Promise}
Mine a single block.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tip |
ChainEntry |
<nullable> |
|
address |
Address |
<nullable> |
- Source:
Returns:
- Returns [Block].
- Type
- Promise
notifyEntry()
Notify the miner that a new tx has entered the mempool.
- Source:
(async) open() → {Promise}
Open the miner.
- Source:
Returns:
- Type
- Promise
sendStatus(job, nonce)
Send a progress report (emits status
).
Parameters:
Name | Type | Description |
---|---|---|
job |
CPUJob | |
nonce |
Number |
- Source:
start()
Start mining.
- Source:
(async) stop() → {Promise}
Stop mining.
- Source:
Returns:
- Type
- Promise
(private) wait() → {Promise}
Wait for done
event.
- Source:
Returns:
- Type
- Promise