Class: Environment

Environment

new Environment(optionsnullable)

A BCoin "environment" which is used for bootstrapping the initial bcoin module. It exposes all constructors for primitives, the blockchain, mempool, wallet, etc. It also sets the default network if there is one. It exposes a global TimeData object for adjusted time, as well as a global worker pool.

Parameters:
Name Type Attributes Description
options Object | NetworkType <nullable>

Options object or network type.

Properties
Name Type Attributes Default Description
network Network | NetworkType <nullable>
prefix String <optional>
~/.bcoin

Prefix for filesystem.

db String <optional>
leveldb

Database backend.

debug Boolean <optional>
false

Whether to display debug output.

debugFile String | Boolean <optional>
~/.bcoin/debug.log

A file to pipe debug output to.

profile Boolean <optional>
false

Enable profiler.

useWorkers Boolean <optional>
false

Enable workers.

maxWorkers Number <optional>
6

Max size of the worker pool.

workerUri String <optional>
/bcoin-worker.js

Location of the bcoin worker.js file for web workers.

proxyServer String <optional>
localhost:8080

Websocket->tcp proxy server for browser.

logger Object <nullable>

Custom logger.

Properties:
Name Type Attributes Description
isBrowser Boolean
networkType NetworkType
bn function

Big number constructor (see https://github.com/indutny/bn.js for docs).

utils Object

module:utils.

locker function

Locker constructor.

reader function

BufferReader constructor.

writer function

BufferWriter constructor.

ec Object

module:ec.

lru function

LRU constructor.

bloom function

Bloom constructor.

bst function

BST constructor.

lowlevelup function

See LowlevelUp.

uri function

See module:uri.

protocol Object
Properties
Name Type Description
constants function

See module:constants.

network function

See module:network.

framer function

Framer constructor.

parser function

Parser constructor.

errors Object
Properties
Name Type Description
VerifyError function

VerifyError constructor.

ScriptError function

ScriptError constructor.

profiler function

module:profiler.

ldb function

See module:ldb.

script function

Script constructor.

stack function

Stack constructor.

witness function

Witness constructor.

input function

Input constructor.

output function

Output constructor.

coin function

Coin constructor.

coins function

Coins constructor.

coinview function

CoinView constructor.

tx function

TX constructor.

mtx function

MTX constructor.

txdb function

TXDB constructor.

abstractblock function

AbstractBlock constructor.

compactblock function

CompactBlock constructor.

block function

Block constructor.

merkleblock function

MerkleBlock constructor.

headers function

Headers constructor.

node function

Node constructor.

spvnode function

SPVNode constructor.

fullnode function

Fullnode constructor.

chainentry function

ChainEntry constructor.

chaindb function

ChainDB constructor.

chain function

Chain constructor.

mempool function

Mempool constructor.

mempoolentry function

MempoolEntry constructor.

keypair function

KeyPair constructor.

hd function

HD constructor.

address function

Address constructor.

wallet function

Wallet constructor.

walletdb function

WalletDB constructor.

provider function

Provider constructor.

peer function

Peer constructor.

pool function

Pool constructor.

miner function

Miner constructor.

minerblock function

MinerBlock constructor.

http Object
Properties
Name Type Description
client function

HTTPClient constructor.

http function

HTTPBase constructor.

provider function

HTTPProvider constructor.

request function

See request.

server function

HTTPServer constructor.

workers Object

See module:workers.

time TimeData

For adjusted time.

workerPool Workers <nullable>

Default global worker pool.

Source:

Methods

debug(obj, …args)

Output a debug message.

Parameters:
Name Type Attributes Description
obj Object | String
args String <repeatable>
Source:
Example
bcoin.debug('foo: %d', 10);

error(err)

Output an error.

Parameters:
Name Type Description
err Error
Source:

mkdir(path, dirnamenullable)

Ensure a directory.

Parameters:
Name Type Attributes Description
path String
dirname Boolean <nullable>
Source:

now() → {Number}

Get the adjusted time.

Source:
Returns:

Adjusted time.

Type
Number

write(msg)

Write a message to the debug log.

Parameters:
Name Type Description
msg String
Source: