chaindb: minor.

This commit is contained in:
Christopher Jeffrey 2017-12-24 02:24:56 -08:00
parent d5a2609f75
commit c63e977ccf
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 14 additions and 11 deletions

View File

@ -881,7 +881,7 @@ class ChainDB {
* @returns {Promise} * @returns {Promise}
*/ */
getHashes(start = -1, end = -1) { async getHashes(start = -1, end = -1) {
if (start === -1) if (start === -1)
start = 0; start = 0;
@ -903,7 +903,7 @@ class ChainDB {
* @returns {Promise} - Returns {@link ChainEntry}[]. * @returns {Promise} - Returns {@link ChainEntry}[].
*/ */
getEntries() { async getEntries() {
return this.db.values({ return this.db.values({
gte: layout.e.min(), gte: layout.e.min(),
lte: layout.e.max(), lte: layout.e.max(),
@ -916,7 +916,7 @@ class ChainDB {
* @returns {Promise} - Returns {@link Hash}[]. * @returns {Promise} - Returns {@link Hash}[].
*/ */
getTips() { async getTips() {
return this.db.keys({ return this.db.keys({
gte: layout.p.min(), gte: layout.p.min(),
lte: layout.p.max(), lte: layout.p.max(),
@ -1178,7 +1178,7 @@ class ChainDB {
gte: layout.C.min(hash), gte: layout.C.min(hash),
lte: layout.C.max(hash), lte: layout.C.max(hash),
parse: (key) => { parse: (key) => {
const [, txid, index] = layout.C.parse(hash); const [, txid, index] = layout.C.parse(key);
return [txid, index]; return [txid, index];
} }
}); });
@ -1212,8 +1212,8 @@ class ChainDB {
gte: layout.T.min(hash), gte: layout.T.min(hash),
lte: layout.T.max(hash), lte: layout.T.max(hash),
parse: (key) => { parse: (key) => {
const [, hash] = layout.T.parse(key); const [, txid] = layout.T.parse(key);
hashes[hash] = true; hashes[txid] = true;
} }
}); });
} }
@ -1251,15 +1251,15 @@ class ChainDB {
addrs = [addrs]; addrs = [addrs];
const hashes = await this.getHashesByAddress(addrs); const hashes = await this.getHashesByAddress(addrs);
const txs = []; const mtxs = [];
for (const hash of hashes) { for (const hash of hashes) {
const tx = await this.getMeta(hash); const mtx = await this.getMeta(hash);
assert(tx); assert(mtx);
txs.push(tx); mtxs.push(mtx);
} }
return txs; return mtxs;
} }
/** /**
@ -2064,6 +2064,7 @@ class ChainFlags {
toRaw() { toRaw() {
const bw = bio.write(12); const bw = bio.write(12);
let flags = 0; let flags = 0;
if (this.spv) if (this.spv)

View File

@ -15,6 +15,7 @@ let parent = null;
const db = bdb.create({ const db = bdb.create({
location: process.argv[2], location: process.argv[2],
memory: false,
compression: true, compression: true,
cacheSize: 32 << 20, cacheSize: 32 << 20,
createIfMissing: false createIfMissing: false

View File

@ -30,6 +30,7 @@ assert(process.argv.length > 2, 'Please pass in a database path.');
const db = bdb.create({ const db = bdb.create({
location: process.argv[2], location: process.argv[2],
memory: false,
compression: true, compression: true,
cacheSize: 32 << 20, cacheSize: 32 << 20,
createIfMissing: false createIfMissing: false