From 124e79907bda9b90d8c8537d6b3014a5776f4baf Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 15 Feb 2016 02:03:09 -0800 Subject: [PATCH] more blockdb cleanup --- lib/bcoin/blockdb.js | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/lib/bcoin/blockdb.js b/lib/bcoin/blockdb.js index deba0564..8d7ea7f2 100644 --- a/lib/bcoin/blockdb.js +++ b/lib/bcoin/blockdb.js @@ -28,11 +28,10 @@ function BlockDB(options) { if (!options) options = {}; - if (typeof options === 'string') - options = { file: options }; + this.file = options.indexFile; - if (!options.file) - options.file = process.env.HOME + '/bcoin-index-' + network.type + '.db'; + if (!this.file) + this.file = process.env.HOME + '/bcoin-index-' + network.type + '.db'; this.options = options; @@ -40,7 +39,7 @@ function BlockDB(options) { this.data = new BlockData(); - this.index = levelup(options.file, { + this.index = levelup(this.file, { keyEncoding: 'ascii', valueEncoding: 'binary', cacheSize: 16 * 1024 * 1024, @@ -52,22 +51,6 @@ function BlockDB(options) { inherits(BlockDB, EventEmitter); -BlockDB.prototype.get = function get(key, options, callback) { - return this.index.get(key, options, callback); -}; - -BlockDB.prototype.put = function put(key, value, options, callback) { - return this.index.put(key, value, options, callback); -}; - -BlockDB.prototype.del = function del(key, options, callback) { - return this.index.del(key, options, callback); -}; - -BlockDB.prototype.batch = function batch() { - return this.index.batch(); -}; - BlockDB.prototype.createOffset = function createOffset(size, offset, height) { var buf = new Buffer(16); utils.writeU32(buf, size, 0); @@ -76,7 +59,7 @@ BlockDB.prototype.createOffset = function createOffset(size, offset, height) { return buf; }; -BlockDB.prototype.parseOffset = function parseOffset(data, height) { +BlockDB.prototype.parseOffset = function parseOffset(data) { return { size: utils.readU32(data, 0), offset: utils.readU64(data, 4).toNumber(), @@ -656,10 +639,10 @@ function BlockData(options) { options = {}; this.options = options; - this.file = options.file; + this.file = options.blockFile; if (!this.file) - this.file = process.env.HOME + '/bcoin-data-' + network.type + '.db'; + this.file = process.env.HOME + '/bcoin-block-' + network.type + '.db'; this._queue = []; this._cache = {};