new WorkerPool(options)
A worker pool.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Properties:
Name | Type | Description |
---|---|---|
size |
Number | |
timeout |
Number | |
children |
Object | |
nonce |
Number |
- Source:
Members
(private, static) bound :Boolean
Whether exit events have been bound globally.
Type:
- Boolean
- Source:
(static) children :Array
Global list of workers.
Type:
- Array
- Source:
(static, constant) CORES :Number
Number of CPUs/cores available.
Type:
- Number
- Source:
(static, constant) support :Boolean
Whether workers are supported.
Type:
- Boolean
- Source:
Methods
(private, static) bindExit()
Bind to process events in order to cleanup listeners.
- Source:
(private, static) cleanup()
Destroy all workers. Used for cleaning up workers on exit.
- Source:
alloc() → {Worker}
Allocate a new worker, will not go above size
option
and will automatically load balance the workers.
- Source:
Returns:
- Type
- Worker
destroy()
Destroy all workers.
- Source:
ecSign(msg, key) → {Promise}
Execute the ec signing job (no timeout).
Parameters:
Name | Type | Description |
---|---|---|
msg |
Buffer | |
key |
Buffer |
- Source:
Returns:
- Type
- Promise
ecVerify(msg, sig, key) → {Promise}
Execute the ec verify job (no timeout).
Parameters:
Name | Type | Description |
---|---|---|
msg |
Buffer | |
sig |
Buffer | DER formatted. |
key |
Buffer |
- Source:
Returns:
- Type
- Promise
execute(packet, timeout) → {Promise}
Call a method for a worker to execute.
Parameters:
Name | Type | Description |
---|---|---|
packet |
Packet | |
timeout |
Number |
- Source:
Returns:
- Type
- Promise
mine(data, target, min, max) → {Promise}
Execute the mining job (no timeout).
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer | |
target |
Buffer | |
min |
Number | |
max |
Number |
- Source:
Returns:
- Returns {Number}.
- Type
- Promise
scrypt(passwd, salt, N, r, p, len) → {Promise}
Execute scrypt job (no timeout).
Parameters:
Name | Type | Description |
---|---|---|
passwd |
Buffer | |
salt |
Buffer | |
N |
Number | |
r |
Number | |
p |
Number | |
len |
Number |
- Source:
Returns:
- Type
- Promise
sendEvent(event, …arg) → {Boolean}
Emit an event on the worker side (all workers).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
event |
String | ||
arg |
Object |
<repeatable> |
- Source:
Returns:
- Type
- Boolean
set(options)
Set worker pool options.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
sign(tx, ring, type) → {Promise}
Execute the tx signing job (default timeout).
Parameters:
Name | Type | Description |
---|---|---|
tx |
MTX | |
ring |
Array:.<KeyRing:> | |
type |
SighashType |
- Source:
Returns:
- Type
- Promise
signInput(tx, index, coin, ring, type) → {Promise}
Execute the tx input signing job (default timeout).
Parameters:
Name | Type | Description |
---|---|---|
tx |
MTX | |
index |
Number | |
coin |
Coin | Output | |
ring |
KeyRing | |
type |
SighashType |
- Source:
Returns:
- Type
- Promise
spawn(id) → {Worker}
Spawn a new worker.
Parameters:
Name | Type | Description |
---|---|---|
id |
Number | Worker ID. |
- Source:
Returns:
- Type
- Worker
verify(tx, view, flags) → {Promise}
Execute the tx verification job (default timeout).
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
view |
CoinView | |
flags |
VerifyFlags |
- Source:
Returns:
- Returns Boolean.
- Type
- Promise
verifyInput(tx, index, coin, flags) → {Promise}
Execute the tx input verification job (default timeout).
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
index |
Number | |
coin |
Coin | Output | |
flags |
VerifyFlags |
- Source:
Returns:
- Returns Boolean.
- Type
- Promise