This commit is contained in:
Christopher Jeffrey 2016-03-18 20:12:34 -07:00
parent 4f805ce52a
commit d690c9ea5a
5 changed files with 19 additions and 7 deletions

View File

@ -11,7 +11,7 @@ var network = bcoin.protocol.network;
var utils = require('./utils');
var assert = utils.assert;
var pad32 = utils.pad32;
var DUMMY = new Buffer([]);
var DUMMY = new Buffer([0]);
/**
* ChainDB

View File

@ -11,8 +11,6 @@ var db = {};
module.exports = function ldb(name, options) {
var levelup = require('levelup');
var file = bcoin.prefix + '/' + name + '-' + network.type + '.db';
var cacheSize = options.cacheSize || 8 * 1024 * 1024;
var writeBufferSize = options.writeBufferSize || (cacheSize / 2 | 0);
bcoin.ensurePrefix();
@ -23,9 +21,15 @@ module.exports = function ldb(name, options) {
createIfMissing: true,
errorIfExists: false,
compression: options.compression !== false,
cacheSize: cacheSize,
writeBufferSize: writeBufferSize,
cacheSize: options.cacheSize || (8 << 20),
writeBufferSize: options.writeBufferSize || (4 << 20),
maxOpenFiles: options.maxOpenFiles || 8192,
// For LMDB if we decide to use it:
sync: options.sync || false,
mapSize: options.mapSize || 150 * (1024 << 20),
writeMap: options.writeMap || false,
db: bcoin.isBrowser
? require('level-js')
: require('level' + 'down')

View File

@ -9,7 +9,7 @@ var bcoin = require('../bcoin');
var utils = require('./utils');
var assert = bcoin.utils.assert;
var EventEmitter = require('events').EventEmitter;
var DUMMY = new Buffer([]);
var DUMMY = new Buffer([0]);
var pad32 = utils.pad32;
/**

View File

@ -1038,6 +1038,14 @@ utils.read32 = function read32(arr, off) {
| (arr[off + 1] << 8)
| (arr[off + 2] << 16)
| (arr[off + 3] << 24);
// arr = (arr[off])
// | (arr[off + 1] << 8)
// | (arr[off + 2] << 16)
// | (arr[off + 3] << 24);
// if (arr & 0x80000000)
// arr = ~arr + 1;
// return arr;
};
utils.read32BE = function read32BE(arr, off) {

View File

@ -9,7 +9,7 @@ var EventEmitter = require('events').EventEmitter;
var bcoin = require('../bcoin');
var utils = require('./utils');
var assert = utils.assert;
var DUMMY = new Buffer([]);
var DUMMY = new Buffer([0]);
/**
* WalletDB