more blockdb cleanup
This commit is contained in:
parent
299126225c
commit
124e79907b
@ -28,11 +28,10 @@ function BlockDB(options) {
|
|||||||
if (!options)
|
if (!options)
|
||||||
options = {};
|
options = {};
|
||||||
|
|
||||||
if (typeof options === 'string')
|
this.file = options.indexFile;
|
||||||
options = { file: options };
|
|
||||||
|
|
||||||
if (!options.file)
|
if (!this.file)
|
||||||
options.file = process.env.HOME + '/bcoin-index-' + network.type + '.db';
|
this.file = process.env.HOME + '/bcoin-index-' + network.type + '.db';
|
||||||
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
@ -40,7 +39,7 @@ function BlockDB(options) {
|
|||||||
|
|
||||||
this.data = new BlockData();
|
this.data = new BlockData();
|
||||||
|
|
||||||
this.index = levelup(options.file, {
|
this.index = levelup(this.file, {
|
||||||
keyEncoding: 'ascii',
|
keyEncoding: 'ascii',
|
||||||
valueEncoding: 'binary',
|
valueEncoding: 'binary',
|
||||||
cacheSize: 16 * 1024 * 1024,
|
cacheSize: 16 * 1024 * 1024,
|
||||||
@ -52,22 +51,6 @@ function BlockDB(options) {
|
|||||||
|
|
||||||
inherits(BlockDB, EventEmitter);
|
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) {
|
BlockDB.prototype.createOffset = function createOffset(size, offset, height) {
|
||||||
var buf = new Buffer(16);
|
var buf = new Buffer(16);
|
||||||
utils.writeU32(buf, size, 0);
|
utils.writeU32(buf, size, 0);
|
||||||
@ -76,7 +59,7 @@ BlockDB.prototype.createOffset = function createOffset(size, offset, height) {
|
|||||||
return buf;
|
return buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
BlockDB.prototype.parseOffset = function parseOffset(data, height) {
|
BlockDB.prototype.parseOffset = function parseOffset(data) {
|
||||||
return {
|
return {
|
||||||
size: utils.readU32(data, 0),
|
size: utils.readU32(data, 0),
|
||||||
offset: utils.readU64(data, 4).toNumber(),
|
offset: utils.readU64(data, 4).toNumber(),
|
||||||
@ -656,10 +639,10 @@ function BlockData(options) {
|
|||||||
options = {};
|
options = {};
|
||||||
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.file = options.file;
|
this.file = options.blockFile;
|
||||||
|
|
||||||
if (!this.file)
|
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._queue = [];
|
||||||
this._cache = {};
|
this._cache = {};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user