db option.
This commit is contained in:
parent
a3720bd42d
commit
1898b38c49
@ -42,6 +42,11 @@ function Environment(options) {
|
||||
|| options.prefix
|
||||
|| process.env.HOME + '/.bcoin';
|
||||
|
||||
this.db = options.db;
|
||||
|
||||
if (process.env.BCOIN_DB != null)
|
||||
this.db = process.env.BCOIN_DB;
|
||||
|
||||
this.debugLogs = options.debug;
|
||||
|
||||
if (process.env.BCOIN_DEBUG != null)
|
||||
|
||||
@ -5,13 +5,12 @@
|
||||
* https://github.com/indutny/bcoin
|
||||
*/
|
||||
|
||||
var db = {};
|
||||
|
||||
module.exports = function(bcoin) {
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var utils = bcoin.utils;
|
||||
var network = bcoin.protocol.network;
|
||||
var db = {};
|
||||
|
||||
/**
|
||||
* LDB
|
||||
@ -55,15 +54,18 @@ function ldb(options) {
|
||||
function getLocation(options) {
|
||||
if (options.location)
|
||||
return options.location;
|
||||
return bcoin.prefix + '/' + options.name + '-' + network.type + '.db';
|
||||
|
||||
return bcoin.prefix
|
||||
+ '/'
|
||||
+ options.name
|
||||
+ '-'
|
||||
+ network.type
|
||||
+ '.db';
|
||||
}
|
||||
|
||||
function getBackend(backend) {
|
||||
if (bcoin.isBrowser)
|
||||
return require('level-js');
|
||||
|
||||
if (typeof backend !== 'string')
|
||||
backend = process.env.BCOIN_DB;
|
||||
backend = bcoin.db;
|
||||
|
||||
if (!backend || backend === 'leveldb')
|
||||
backend = 'leveldown';
|
||||
@ -77,6 +79,9 @@ function getBackend(backend) {
|
||||
if (backend === 'bst')
|
||||
return require('./bst');
|
||||
|
||||
if (bcoin.isBrowser)
|
||||
return require('level-js');
|
||||
|
||||
bcoin.ensurePrefix();
|
||||
|
||||
return require(backend);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
"bin": "./bin/node",
|
||||
"preferGlobal": false,
|
||||
"scripts": {
|
||||
"test": "rm -rf ~/.bcoin-test && BCOIN_PREFIX=~/.bcoin-test mocha --reporter spec test/*-test.js"
|
||||
"test": "mocha --reporter spec test/*-test.js"
|
||||
},
|
||||
"repository": "git://github.com/bcoin-org/bcoin.git",
|
||||
"keywords": [
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
var bn = require('bn.js');
|
||||
var bcoin = require('../')();
|
||||
var bcoin = require('../')({ db: 'memory' });
|
||||
var constants = bcoin.protocol.constants;
|
||||
var utils = bcoin.utils;
|
||||
var assert = utils.assert;
|
||||
var opcodes = constants.opcodes;
|
||||
|
||||
describe('Wallet', function() {
|
||||
process.env.BCOIN_DB = 'bst';
|
||||
var node = new bcoin.fullnode();
|
||||
node.on('error', function() {});
|
||||
|
||||
@ -15,7 +14,6 @@ describe('Wallet', function() {
|
||||
});
|
||||
|
||||
it('should have wallet', function(cb) {
|
||||
delete process.env.BCOIN_DB;
|
||||
node.getWallet('primary', function(err, wallet) {
|
||||
if (err)
|
||||
return cb(err);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var bn = require('bn.js');
|
||||
var bcoin = require('../')();
|
||||
var bcoin = require('../')({ db: 'memory' });
|
||||
var constants = bcoin.protocol.constants;
|
||||
var utils = bcoin.utils;
|
||||
var assert = utils.assert;
|
||||
@ -24,8 +24,11 @@ var dummyInput = {
|
||||
};
|
||||
|
||||
describe('Wallet', function() {
|
||||
var wdb = new bcoin.walletdb();
|
||||
wdb.tx.options.verify = true;
|
||||
var wdb = new bcoin.walletdb({ verify: true });
|
||||
|
||||
it('should open walletdb', function(cb) {
|
||||
wdb.open(cb);
|
||||
});
|
||||
|
||||
it('should generate new key and address', function() {
|
||||
var w = bcoin.wallet();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user