ldb: max open files.

This commit is contained in:
Christopher Jeffrey 2016-08-24 07:44:06 -07:00
parent ad46d3e243
commit 0b9e3df545
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
7 changed files with 22 additions and 15 deletions

View File

@ -1,4 +1,4 @@
# Default bcoin config file (~/.bcoin/bcoin.conf)
# Sample bcoin config file (~/.bcoin/bcoin.conf)
# Options
network: main
@ -15,6 +15,7 @@ log-file: true
# Node
# prefix: ~/.bcoin
db: leveldb
max-files: 64
# fast: false
# Chain

View File

@ -233,6 +233,7 @@ function ChainDB(chain, options) {
this.db = bcoin.ldb({
location: this.options.location,
db: this.options.db,
maxOpenFiles: this.options.maxFiles,
compression: true,
cacheSize: 16 << 20,
writeBufferSize: 8 << 20,

View File

@ -29,19 +29,19 @@ var assert = utils.assert;
*/
function ldb(options) {
options = ldb.parseOptions(options);
var target = ldb.getTarget(options);
if (options.backend !== 'rbt')
utils.mkdir(options.location, true);
if (target.backend !== 'rbt')
utils.mkdir(target.location, true);
return new LowlevelUp(options.location, {
return new LowlevelUp(target.location, {
// LevelDB and others
createIfMissing: options.createIfMissing !== false,
errorIfExists: options.errorIfExists === true,
compression: options.compression !== false,
cacheSize: options.cacheSize || (8 << 20),
writeBufferSize: options.writeBufferSize || (4 << 20),
maxOpenFiles: options.maxOpenFiles || 8192,
maxOpenFiles: options.maxOpenFiles || 64,
filterBits: 0,
paranoidChecks: false,
memory: false,
@ -54,7 +54,7 @@ function ldb(options) {
// For browser buffer keys
bufferKeys: options.bufferKeys,
db: options.db
db: target.db
});
}
@ -103,12 +103,12 @@ ldb.getBackend = function getBackend(db) {
};
/**
* Parse options.
* Get target backend and location.
* @param {Object} options
* @returns {Object}
*/
ldb.parseOptions = function parseOptions(options) {
ldb.getTarget = function getTarget(options) {
var backend = ldb.getBackend(options.db);
var location = options.location;
var db;
@ -125,12 +125,11 @@ ldb.parseOptions = function parseOptions(options) {
location = 'rbt';
}
return utils.merge({}, options, {
return {
db: db,
backend: backend.name,
ext: backend.ext,
location: location + '.' + backend.ext,
db: db
});
location: location + '.' + backend.ext
};
};
/*

View File

@ -133,6 +133,7 @@ config.parseData = function parseData(data) {
// Node
options.prefix = path(data.prefix);
options.db = str(data.db);
options.maxFiles = num(data.maxfiles);
options.fast = bool(data.fast);
// Chain

View File

@ -66,7 +66,8 @@ function Fullnode(options) {
useCheckpoints: this.options.useCheckpoints,
coinCache: this.options.coinCache,
indexTX: this.options.indexTX,
indexAddress: this.options.indexAddress
indexAddress: this.options.indexAddress,
maxFiles: this.options.maxFiles
});
// Fee estimation.
@ -135,6 +136,7 @@ function Fullnode(options) {
location: this.location('walletdb'),
witness: this.options.witness,
useCheckpoints: this.options.useCheckpoints,
maxFiles: this.options.maxFiles,
verify: false
});

View File

@ -48,6 +48,7 @@ function SPVNode(options) {
location: this.location('spvchain'),
witness: this.options.witness,
useCheckpoints: this.options.useCheckpoints,
maxFiles: this.options.maxFiles,
spv: true
});
@ -75,6 +76,7 @@ function SPVNode(options) {
db: this.db,
location: this.location('walletdb'),
witness: this.options.witness,
maxFiles: this.options.maxFiles,
verify: true
});

View File

@ -190,6 +190,7 @@ function WalletDB(options) {
this.db = bcoin.ldb({
location: this.options.location,
db: this.options.db,
maxOpenFiles: this.options.maxFiles,
cacheSize: 8 << 20,
writeBufferSize: 4 << 20,
bufferKeys: true