diff --git a/lib/bcoin/blockdb.js b/lib/bcoin/blockdb.js index 45cf4d2d..ee22765d 100644 --- a/lib/bcoin/blockdb.js +++ b/lib/bcoin/blockdb.js @@ -59,7 +59,7 @@ function BlockDB(options) { maxOpenFiles: 8192, // blockRestartInterval: 16, db: bcoin.isBrowser - ? require('memdown') + ? require('level-js') : require('level' + 'down') }); } diff --git a/lib/bcoin/pool.js b/lib/bcoin/pool.js index 4f5375fb..c8543c57 100644 --- a/lib/bcoin/pool.js +++ b/lib/bcoin/pool.js @@ -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); }); diff --git a/lib/bcoin/walletdb.js b/lib/bcoin/walletdb.js index c98f32c8..dbe90118 100644 --- a/lib/bcoin/walletdb.js +++ b/lib/bcoin/walletdb.js @@ -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); }; diff --git a/package.json b/package.json index 17f6e363..cb93dc00 100644 --- a/package.json +++ b/package.json @@ -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" },