env variables.
This commit is contained in:
parent
703c9aec3c
commit
bba94d4aaa
@ -125,23 +125,26 @@ function Environment(options) {
|
|||||||
(typeof process !== 'undefined' && process.browser)
|
(typeof process !== 'undefined' && process.browser)
|
||||||
|| typeof window !== 'undefined';
|
|| typeof window !== 'undefined';
|
||||||
|
|
||||||
this.prefix = process.env.BCOIN_PREFIX
|
this.prefix = options.prefix
|
||||||
|| options.prefix
|
|| process.env.BCOIN_PREFIX
|
||||||
|| process.env.HOME + '/.bcoin';
|
|| process.env.HOME + '/.bcoin';
|
||||||
|
|
||||||
this.db = options.db;
|
this.networkType = options.network
|
||||||
|
|| process.env.BCOIN_NETWORK
|
||||||
if (process.env.BCOIN_DB != null)
|
|| 'main';
|
||||||
this.db = process.env.BCOIN_DB;
|
|
||||||
|
|
||||||
|
this.db = options.db || process.env.BCOIN_DB;
|
||||||
this.debugLogs = options.debug;
|
this.debugLogs = options.debug;
|
||||||
|
this.debugFile = options.debugFile;
|
||||||
|
this.profile = options.profile;
|
||||||
|
this.useWorkers = options.useWorkers;
|
||||||
|
this.maxWorkers = options.maxWorkers;
|
||||||
|
this.workerTimeout = options.workerTimeout;
|
||||||
|
|
||||||
if (process.env.BCOIN_DEBUG != null)
|
if (this.debugLogs == null && process.env.BCOIN_DEBUG != null)
|
||||||
this.debugLogs = +process.env.BCOIN_DEBUG === 1;
|
this.debugLogs = +process.env.BCOIN_DEBUG === 1;
|
||||||
|
|
||||||
this.debugFile = options.debugFile;
|
if (this.debugFile == null && process.env.BCOIN_DEBUGFILE != null) {
|
||||||
|
|
||||||
if (process.env.BCOIN_DEBUGFILE != null) {
|
|
||||||
if (process.env.BCOIN_DEBUGFILE === '0'
|
if (process.env.BCOIN_DEBUGFILE === '0'
|
||||||
|| process.env.BCOIN_DEBUGFILE === '1') {
|
|| process.env.BCOIN_DEBUGFILE === '1') {
|
||||||
this.debugFile = +process.env.BCOIN_DEBUGFILE !== 0;
|
this.debugFile = +process.env.BCOIN_DEBUGFILE !== 0;
|
||||||
@ -153,30 +156,18 @@ function Environment(options) {
|
|||||||
if (this.debugFile && typeof this.debugFile !== 'string')
|
if (this.debugFile && typeof this.debugFile !== 'string')
|
||||||
this.debugFile = this.prefix + '/debug.log'
|
this.debugFile = this.prefix + '/debug.log'
|
||||||
|
|
||||||
this.profile = options.profile;
|
if (this.profile == null && process.env.BCOIN_PROFILE != null)
|
||||||
|
|
||||||
if (process.env.BCOIN_PROFILE != null)
|
|
||||||
this.profile = +process.env.BCOIN_PROFILE === 1;
|
this.profile = +process.env.BCOIN_PROFILE === 1;
|
||||||
|
|
||||||
this.useWorkers = options.useWorkers;
|
if (this.useWorkers == null && process.env.BCOIN_USE_WORKERS != null)
|
||||||
|
|
||||||
if (process.env.BCOIN_USE_WORKERS != null)
|
|
||||||
this.useWorkers = +process.env.BCOIN_USE_WORKERS === 1;
|
this.useWorkers = +process.env.BCOIN_USE_WORKERS === 1;
|
||||||
|
|
||||||
this.useWorkers = options.maxWorkers;
|
if (this.maxWorkers == null && process.env.BCOIN_MAX_WORKERS != null)
|
||||||
|
|
||||||
if (process.env.BCOIN_MAX_WORKERS != null)
|
|
||||||
this.maxWorkers = +process.env.BCOIN_MAX_WORKERS;
|
this.maxWorkers = +process.env.BCOIN_MAX_WORKERS;
|
||||||
|
|
||||||
this.workerTimeout = options.workerTimeout;
|
if (this.workerTime == null && process.env.BCOIN_WORKER_TIMEOUT != null)
|
||||||
|
|
||||||
if (process.env.BCOIN_WORKER_TIMEOUT != null)
|
|
||||||
this.workerTimeout = +process.env.BCOIN_WORKER_TIMEOUT;
|
this.workerTimeout = +process.env.BCOIN_WORKER_TIMEOUT;
|
||||||
|
|
||||||
this.networkType = process.env.BCOIN_NETWORK
|
|
||||||
|| options.network
|
|
||||||
|| 'main';
|
|
||||||
|
|
||||||
this.bn = require('bn.js');
|
this.bn = require('bn.js');
|
||||||
this.utils = require('./utils');
|
this.utils = require('./utils');
|
||||||
this.locker = require('./locker');
|
this.locker = require('./locker');
|
||||||
|
|||||||
@ -51,7 +51,7 @@ function ldb(options) {
|
|||||||
|
|
||||||
// For LMDB if we decide to use it:
|
// For LMDB if we decide to use it:
|
||||||
sync: options.sync || false,
|
sync: options.sync || false,
|
||||||
mapSize: options.mapSize || 150 * (1024 << 20),
|
mapSize: options.mapSize || 300 * (1024 << 20),
|
||||||
writeMap: options.writeMap || false,
|
writeMap: options.writeMap || false,
|
||||||
|
|
||||||
db: getBackend(options.db)
|
db: getBackend(options.db)
|
||||||
@ -74,7 +74,7 @@ function getLocation(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getBackend(backend) {
|
function getBackend(backend) {
|
||||||
if (typeof backend !== 'string')
|
if (!backend)
|
||||||
backend = bcoin.db;
|
backend = bcoin.db;
|
||||||
|
|
||||||
if (!backend || backend === 'leveldb')
|
if (!backend || backend === 'leveldb')
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
},
|
},
|
||||||
"preferGlobal": false,
|
"preferGlobal": false,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "BCOIN_NETWORK=main mocha --reporter spec test/*-test.js"
|
"test": "mocha --reporter spec test/*-test.js"
|
||||||
},
|
},
|
||||||
"repository": "git://github.com/bcoin-org/bcoin.git",
|
"repository": "git://github.com/bcoin-org/bcoin.git",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
var bn = require('bn.js');
|
var bn = require('bn.js');
|
||||||
var bcoin = require('../')();
|
var utils = require('../lib/bcoin/utils');
|
||||||
var utils = bcoin.utils;
|
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var aes = require('../lib/bcoin/aes');
|
var aes = require('../lib/bcoin/aes');
|
||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
var bn = require('bn.js');
|
var bn = require('bn.js');
|
||||||
var bcoin = require('../')();
|
var bcoin = require('../')('main');
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
|
||||||
describe('Block', function() {
|
describe('Block', function() {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
var bcoin = require('../')();
|
var bcoin = require('../')('main');
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
|
||||||
describe('Bloom', function() {
|
describe('Bloom', function() {
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
var bn = require('bn.js');
|
var bn = require('bn.js');
|
||||||
delete process.env.BCOIN_NETWORK;
|
var bcoin = require('../')('regtest');
|
||||||
var bcoin = require('../')({ network: 'regtest', db: 'memory' });
|
|
||||||
process.env.BCOIN_NETWORK = 'main';
|
|
||||||
var constants = bcoin.protocol.constants;
|
var constants = bcoin.protocol.constants;
|
||||||
var utils = bcoin.utils;
|
var utils = bcoin.utils;
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
@ -13,7 +11,7 @@ describe('Chain', function() {
|
|||||||
var chain, wallet, miner;
|
var chain, wallet, miner;
|
||||||
var competingTip, oldTip, ch1, ch2, cb1, cb2;
|
var competingTip, oldTip, ch1, ch2, cb1, cb2;
|
||||||
|
|
||||||
chain = new bcoin.chain();
|
chain = new bcoin.chain({ name: 'chain-test', db: 'memory' });
|
||||||
wallet = new bcoin.wallet();
|
wallet = new bcoin.wallet();
|
||||||
miner = new bcoin.miner({
|
miner = new bcoin.miner({
|
||||||
chain: chain,
|
chain: chain,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
var bn = require('bn.js');
|
var bn = require('bn.js');
|
||||||
var bcoin = require('../')();
|
var bcoin = require('../')('main');
|
||||||
var utils = bcoin.utils;
|
var utils = bcoin.utils;
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,22 @@
|
|||||||
var bn = require('bn.js');
|
var bn = require('bn.js');
|
||||||
var bcoin = require('../')();
|
var bcoin = require('../')('main');
|
||||||
var constants = bcoin.protocol.constants;
|
var constants = bcoin.protocol.constants;
|
||||||
var utils = bcoin.utils;
|
var utils = bcoin.utils;
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var opcodes = constants.opcodes;
|
var opcodes = constants.opcodes;
|
||||||
|
|
||||||
describe('Mempool', function() {
|
describe('Mempool', function() {
|
||||||
var chain = new bcoin.chain({ db: 'memory' });
|
var chain = new bcoin.chain({
|
||||||
var mempool = new bcoin.mempool({ chain: chain, db: 'memory' });
|
name: 'mp-chain',
|
||||||
|
db: 'memory'
|
||||||
|
});
|
||||||
|
|
||||||
|
var mempool = new bcoin.mempool({
|
||||||
|
chain: chain,
|
||||||
|
name: 'mempool-test',
|
||||||
|
db: 'memory'
|
||||||
|
});
|
||||||
|
|
||||||
mempool.on('error', function() {});
|
mempool.on('error', function() {});
|
||||||
|
|
||||||
it('should open mempool', function(cb) {
|
it('should open mempool', function(cb) {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
var bn = require('bn.js');
|
var bn = require('bn.js');
|
||||||
var bcoin = require('../')();
|
var bcoin = require('../')('main');
|
||||||
var utils = bcoin.utils;
|
var utils = bcoin.utils;
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var mnemonic1 = require('./data/mnemonic1').english;
|
var mnemonic1 = require('./data/mnemonic1').english;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
var bcoin = require('../')();
|
var bcoin = require('../')('main');
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var constants = bcoin.protocol.constants;
|
var constants = bcoin.protocol.constants;
|
||||||
var network = bcoin.protocol.network;
|
var network = bcoin.protocol.network;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
var bcoin = require('../')();
|
var bcoin = require('../')('main');
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var Script = bcoin.script;
|
var Script = bcoin.script;
|
||||||
var Stack = bcoin.script.stack;
|
var Stack = bcoin.script.stack;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
var bn = require('bn.js');
|
var bn = require('bn.js');
|
||||||
var bcoin = require('../')();
|
var bcoin = require('../')('main');
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var utils = bcoin.utils;
|
var utils = bcoin.utils;
|
||||||
var constants = bcoin.protocol.constants;
|
var constants = bcoin.protocol.constants;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
var bn = require('bn.js');
|
var bn = require('bn.js');
|
||||||
var bcoin = require('../')();
|
var bcoin = require('../')('main');
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var utils = bcoin.utils;
|
var utils = bcoin.utils;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
var bn = require('bn.js');
|
var bn = require('bn.js');
|
||||||
var bcoin = require('../').env();
|
var bcoin = require('../')('main');
|
||||||
var constants = bcoin.protocol.constants;
|
var constants = bcoin.protocol.constants;
|
||||||
|
var network = bcoin.protocol.network;
|
||||||
var utils = bcoin.utils;
|
var utils = bcoin.utils;
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
|
||||||
@ -24,9 +25,14 @@ var dummyInput = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
describe('Wallet', function() {
|
describe('Wallet', function() {
|
||||||
var wdb = new bcoin.walletdb({ db: 'memory', verify: true });
|
var wdb = new bcoin.walletdb({
|
||||||
|
name: 'wallet-test',
|
||||||
|
db: 'memory',
|
||||||
|
verify: true
|
||||||
|
});
|
||||||
|
|
||||||
it('should open walletdb', function(cb) {
|
it('should open walletdb', function(cb) {
|
||||||
|
constants.tx.COINBASE_MATURITY = 0;
|
||||||
wdb.open(cb);
|
wdb.open(cb);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -554,4 +560,8 @@ describe('Wallet', function() {
|
|||||||
it('should verify 2-of-3 witnessscripthash tx with bullshit nesting', function(cb) {
|
it('should verify 2-of-3 witnessscripthash tx with bullshit nesting', function(cb) {
|
||||||
multisig(true, true, cb);
|
multisig(true, true, cb);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should cleanup', function(cb) {
|
||||||
|
constants.tx.COINBASE_MATURITY = 100;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user