hypercore-storage 1.6.2 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +12 -4
- package/lib/block-dependency-stream.js +5 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -310,7 +310,7 @@ class CorestoreStorage {
|
|
|
310
310
|
constructor (db, opts) {
|
|
311
311
|
this.path = typeof db === 'string' ? db : db.path
|
|
312
312
|
this.rocks = typeof db === 'string' ? new RocksDB(db, opts) : db
|
|
313
|
-
this.db = createColumnFamily(this.rocks)
|
|
313
|
+
this.db = createColumnFamily(this.rocks, opts)
|
|
314
314
|
this.view = null
|
|
315
315
|
this.enters = 0
|
|
316
316
|
this.lock = new ScopeLock()
|
|
@@ -750,15 +750,23 @@ function isCorestoreStorage (s) {
|
|
|
750
750
|
return typeof s === 'object' && !!s && typeof s.setDefaultDiscoveryKey === 'function'
|
|
751
751
|
}
|
|
752
752
|
|
|
753
|
-
function createColumnFamily (db) {
|
|
753
|
+
function createColumnFamily (db, opts = {}) {
|
|
754
|
+
const {
|
|
755
|
+
tableCacheIndexAndFilterBlocks = true,
|
|
756
|
+
blockCache = true,
|
|
757
|
+
optimizeFiltersForMemory = false
|
|
758
|
+
} = opts
|
|
759
|
+
|
|
754
760
|
const col = new RocksDB.ColumnFamily(COLUMN_FAMILY, {
|
|
755
761
|
enableBlobFiles: true,
|
|
756
762
|
minBlobSize: 4096,
|
|
757
763
|
blobFileSize: 256 * 1024 * 1024,
|
|
758
764
|
enableBlobGarbageCollection: true,
|
|
759
765
|
tableBlockSize: 8192,
|
|
760
|
-
tableCacheIndexAndFilterBlocks
|
|
761
|
-
tableFormatVersion: 6
|
|
766
|
+
tableCacheIndexAndFilterBlocks,
|
|
767
|
+
tableFormatVersion: 6,
|
|
768
|
+
optimizeFiltersForMemory,
|
|
769
|
+
blockCache
|
|
762
770
|
})
|
|
763
771
|
|
|
764
772
|
return db.columnFamily(col)
|
|
@@ -27,11 +27,12 @@ module.exports = class BlockStream extends Readable {
|
|
|
27
27
|
const deps = this.core.dependencies
|
|
28
28
|
const index = this._findDependencyIndex(deps)
|
|
29
29
|
|
|
30
|
-
const curr = deps[index]
|
|
31
|
-
const prev = deps[index - 1]
|
|
30
|
+
const curr = index < deps.length ? deps[index] : null
|
|
31
|
+
const prev = (index > 0 && index - 1 < deps.length) ? deps[index - 1] : null
|
|
32
|
+
|
|
33
|
+
const start = (prev && prev.length > this.start) ? prev.length : this.start
|
|
34
|
+
const end = (curr && (this.end === -1 || curr.length < this.end)) ? curr.length : this.end
|
|
32
35
|
|
|
33
|
-
const start = prev && prev.length > this.start ? prev.length : this.start
|
|
34
|
-
const end = curr && curr.length < this.end ? curr.length : this.end
|
|
35
36
|
const ptr = curr ? curr.dataPointer : this.core.dataPointer
|
|
36
37
|
|
|
37
38
|
this._makeStream(core.block(ptr, start), core.block(ptr, end))
|