hypercore-storage 3.0.2 → 3.1.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.
Files changed (2) hide show
  1. package/index.js +18 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -524,8 +524,8 @@ class CorestoreStorage {
524
524
  return this.db.ready()
525
525
  }
526
526
 
527
- compact() {
528
- return this.db.compactRange()
527
+ compact(opts) {
528
+ return this.db.compactRange(opts)
529
529
  }
530
530
 
531
531
  async audit() {
@@ -1006,9 +1006,15 @@ class CorestoreStorage {
1006
1006
  return Promise.all(resultPromises)
1007
1007
  }
1008
1008
 
1009
- async suspend() {
1009
+ async suspend({ log = noop } = {}) {
1010
+ await log('Suspending hypercore storage...')
1010
1011
  await this.db.suspend()
1011
- if (this.deviceFile) await this.deviceFile.suspend()
1012
+ await log('db suspended')
1013
+ if (this.deviceFile) {
1014
+ await log('suspend deviceFile')
1015
+ await this.deviceFile.suspend()
1016
+ await log('deviceFile suspended')
1017
+ }
1012
1018
  }
1013
1019
 
1014
1020
  async resume() {
@@ -1228,19 +1234,24 @@ function createColumnFamily(db, opts = {}) {
1228
1234
  const {
1229
1235
  tableCacheIndexAndFilterBlocks = true,
1230
1236
  blockCache = true,
1231
- optimizeFiltersForMemory = false
1237
+ optimizeFiltersForMemory = false,
1238
+ blobFileSize = 256 * 1024 * 1024,
1239
+ blobGarbageCollectionAgeCutOff = 0.25,
1240
+ blobGarbageCollectionForceThreshold = 1.0
1232
1241
  } = opts
1233
1242
 
1234
1243
  const col = new RocksDB.ColumnFamily(COLUMN_FAMILY, {
1235
1244
  enableBlobFiles: true,
1236
1245
  minBlobSize: 4096,
1237
- blobFileSize: 256 * 1024 * 1024,
1246
+ blobFileSize,
1238
1247
  enableBlobGarbageCollection: true,
1239
1248
  tableBlockSize: 8192,
1240
1249
  tableCacheIndexAndFilterBlocks,
1241
1250
  tableFormatVersion: 6,
1242
1251
  optimizeFiltersForMemory,
1243
- blockCache
1252
+ blockCache,
1253
+ blobGarbageCollectionAgeCutOff,
1254
+ blobGarbageCollectionForceThreshold
1244
1255
  })
1245
1256
 
1246
1257
  return db.columnFamily(col)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-storage",
3
- "version": "3.0.2",
3
+ "version": "3.1.1",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js",