use level-js in the browser instead of memdown.

This commit is contained in:
Christopher Jeffrey 2016-02-20 21:33:58 -08:00
parent b11cdd80af
commit e7478372cf
4 changed files with 14 additions and 7 deletions

View File

@ -59,7 +59,7 @@ function BlockDB(options) {
maxOpenFiles: 8192,
// blockRestartInterval: 16,
db: bcoin.isBrowser
? require('memdown')
? require('level-js')
: require('level' + 'down')
});
}

View File

@ -1199,8 +1199,10 @@ Pool.prototype.addWallet = function addWallet(wallet, callback) {
function search() {
// Relay pending TXs
// NOTE: It is important to do it after search, because search could
// add TS to pending TXs, thus making them confirmed
// NOTE: It is important to do it after
// search, because search could add TS
// to pending TXs, thus making them
// confirmed.
wallet.pending().forEach(function(tx) {
self.sendTX(tx);
});

View File

@ -33,7 +33,10 @@ function WalletDB(options) {
EventEmitter.call(this);
this.options = options;
this.file = options.file;
this.dir = options.dir;
this.type = options.type;
if (!this.file)
this.file = bcoin.dir + '/wallet-' + network.type + '.db';
@ -42,7 +45,7 @@ function WalletDB(options) {
this.dir = bcoin.dir + '/wallet-' + network.type;
if (!this.type)
this.type = 'file';
this.type = 'leveldb';
WalletDB.global = this;
@ -83,7 +86,7 @@ WalletDB.prototype._init = function _init() {
if (!WalletDB._db[this.file]) {
WalletDB._db[this.file] = new levelup(this.file, {
keyEncoding: 'ascii',
valueEncoding: 'json',
valueEncoding: 'utf8',
createIfMissing: true,
errorIfExists: false,
compression: true,
@ -93,7 +96,7 @@ WalletDB.prototype._init = function _init() {
maxOpenFiles: 1024,
// blockRestartInterval: 16,
db: bcoin.isBrowser
? require('memdown')
? require('level-js')
: require('level' + 'down')
});
}
@ -129,6 +132,8 @@ WalletDB.prototype.saveDB = function saveFile(id, json, callback) {
callback = utils.asyncify(callback);
json = JSON.stringify(json);
this.db.put(key, json, callback);
};

View File

@ -29,7 +29,7 @@
"hash.js": "1.0.3",
"inherits": "2.0.1",
"leveldown": "1.4.4",
"memdown": "1.1.2",
"level-js": "2.2.3",
"levelup": "1.3.1",
"request": "2.67.0"
},