options.
This commit is contained in:
parent
f71aa44acc
commit
d1695bf014
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
var utils = require('./utils');
|
||||
var global = utils.global;
|
||||
var fs;
|
||||
|
||||
if (!utils.isBrowser)
|
||||
@ -26,16 +27,20 @@ if (!utils.isBrowser)
|
||||
*
|
||||
* @param {(Object|NetworkType)?} options - Options object or network type.
|
||||
* @param {(Network|NetworkType)?} options.network
|
||||
* @param {String?} options.prefix - Prefix for filesystem (default=~/.bcoin).
|
||||
* @param {String?} options.db - Database backend (default=leveldb).
|
||||
* @param {Boolean?} options.debug - Whether to display debug output.
|
||||
* @param {(String|Boolean)?} options.debugFile - A file to
|
||||
* @param {String} [options.prefix=~/.bcoin] - Prefix for filesystem.
|
||||
* @param {String} [options.db=leveldb] - Database backend.
|
||||
* @param {Boolean} [options.debug=false] - Whether to display debug output.
|
||||
* @param {String|Boolean} [options.debugFile=~/.bcoin/debug.log] - A file to
|
||||
* pipe debug output to.
|
||||
* @param {Boolean?} options.profile - Enable profiler.
|
||||
* @param {Boolean?} options.useWorkers - Enable workers.
|
||||
* @param {Number?} options.maxWorkers - Max size of
|
||||
* the worker pool (default=6).
|
||||
*
|
||||
* @param {Boolean} [options.profile=false] - Enable profiler.
|
||||
* @param {Boolean} [options.useWorkers=false] - Enable workers.
|
||||
* @param {Number} [options.maxWorkers=6] - Max size of
|
||||
* the worker pool.
|
||||
* @param {String} [options.workerUri=/bcoin-worker.js] Location of the bcoin
|
||||
* worker.js file for web workers.
|
||||
* @param {String} [options.proxyServer=localhost:8080] -
|
||||
* Websocket->tcp proxy server for browser.
|
||||
* @param {Object?} options.logger - Custom logger.
|
||||
* @property {Boolean} isBrowser
|
||||
* @property {NetworkType} networkType
|
||||
*
|
||||
@ -189,8 +194,8 @@ function Environment(options) {
|
||||
this.useWorkers = null;
|
||||
this.maxWorkers = null;
|
||||
this.workerTimeout = null;
|
||||
this.proxyServer = null;
|
||||
this.workerUri = null;
|
||||
this.proxyServer = null;
|
||||
this.logger = null;
|
||||
|
||||
this.time = new this.timedata();
|
||||
@ -267,8 +272,8 @@ Environment.prototype.set = function set(options) {
|
||||
this.network.set(this.networkType);
|
||||
|
||||
if (this.isBrowser && this.useWorkers) {
|
||||
this.useWorkers = typeof utils.global.Worker === 'function'
|
||||
|| typeof utils.global.postMessage === 'function';
|
||||
this.useWorkers = typeof global.Worker === 'function'
|
||||
|| typeof global.postMessage === 'function';
|
||||
}
|
||||
|
||||
if (this.useWorkers) {
|
||||
@ -318,8 +323,11 @@ Environment.prototype.debug = function debug() {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var msg;
|
||||
|
||||
if (this.logger)
|
||||
this.logger.debug(args);
|
||||
if (this.logger) {
|
||||
if (this.debugLogs)
|
||||
this.logger.debug(args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isBrowser) {
|
||||
if (this.debugLogs) {
|
||||
@ -356,8 +364,11 @@ Environment.prototype.error = function error(err) {
|
||||
if (typeof err === 'string')
|
||||
err = new Error(err);
|
||||
|
||||
if (this.logger)
|
||||
this.logger.error(err);
|
||||
if (this.logger) {
|
||||
if (this.debugLogs)
|
||||
this.logger.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isBrowser) {
|
||||
if (this.debugLogs)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user