more blockdb cleanup

This commit is contained in:
Christopher Jeffrey 2016-02-15 02:03:09 -08:00
parent 299126225c
commit 124e79907b

View File

@ -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 = {};