hypercore 11.35.2 → 11.35.3

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.
@@ -1,6 +1,7 @@
1
1
  const BigSparseArray = require('big-sparse-array')
2
2
  const { Transform } = require('streamx')
3
3
  const quickbit = require('./compat').quickbit
4
+ const Mutex = require('./mutex')
4
5
  const b4a = require('b4a')
5
6
 
6
7
  const BITS_PER_PAGE = 32768
@@ -34,6 +35,7 @@ module.exports = class MarkBitfield {
34
35
 
35
36
  constructor(storage) {
36
37
  this.storage = storage
38
+ this.mutex = new Mutex()
37
39
  this._pages = new BigSparseArray()
38
40
  }
39
41
 
@@ -68,9 +70,11 @@ module.exports = class MarkBitfield {
68
70
  if (p) {
69
71
  await p.loaded
70
72
  p.set(j, val)
73
+ await this.mutex.lock()
71
74
  const tx = this.storage.write()
72
75
  tx.putMark(i, p.bitfield)
73
76
  await tx.flush()
77
+ this.mutex.unlock()
74
78
  }
75
79
  }
76
80
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.35.2",
3
+ "version": "11.35.3",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {