Class: Miner

mining.Miner

new Miner(options)

A bitcoin miner (supports mining witness blocks).

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
address Address

Payout address.

coinbaseFlags String <optional>
"mined by bcoin"
Properties:
Name Type Description
running Boolean
attempt MinerBlock
Source:
Fires:
  • Miner#event:block
  • Miner#event:status

Methods

(private) _createBlock(tip) → {Promise}

Create a block "attempt" (without a lock).

Parameters:
Name Type Description
tip ChainEntry
Source:
Returns:
  • Returns MinerBlock.
Type
Promise

(private) _init()

Initialize the miner.

Source:

(private) _onDone() → {Promise}

Wait for done event.

Source:
Returns:
Type
Promise

(private) _onStop() → {Promise}

Wait for stop event.

Source:
Returns:
Type
Promise

addAddress(address)

Add an address to the address list.

Parameters:
Name Type Description
address Address
Source:

build() → {Array:.<MempoolEntry:>}

Get mempool entries, sort by dependency order. Prioritize by priority and fee rates.

Source:
Returns:
Type
Array:.<MempoolEntry:>

close() → {Promise}

Close the miner.

Source:
Returns:
Type
Promise

createBlock(tip) → {Promise}

Create a block "attempt".

Parameters:
Name Type Description
tip ChainEntry
Source:
Returns:
  • Returns MinerBlock.
Type
Promise

getAddress() → {Address}

Get a random address from the address list.

Source:
Returns:
Type
Address

mineBlock(tip) → {Promise}

Mine a single block.

Parameters:
Name Type Description
tip ChainEntry
Source:
Returns:
Type
Promise

notifyEntry(entry)

Notify the miner that a new tx has entered the mempool.

Parameters:
Name Type Description
entry MempoolEntry
Source:

open() → {Promise}

Open the miner, wait for the chain and mempool to load.

Source:
Returns:
Type
Promise

start(versionnullable) → {Promise}

Start mining.

Parameters:
Name Type Attributes Description
version Number <nullable>

Custom block version.

Source:
Returns:
Type
Promise

stop() → {Promise}

Stop mining.

Source:
Returns:
Type
Promise