hypercore 10.3.0 → 10.3.2

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 +11 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -171,14 +171,14 @@ module.exports = class Hypercore extends EventEmitter {
171
171
 
172
172
  const directory = storage
173
173
  const toLock = opts.unlocked ? null : (opts.lock || 'oplog')
174
- const pool = opts.pool || null
174
+ const pool = opts.pool || (opts.poolSize ? RAF.createPool(opts.poolSize) : null)
175
175
 
176
176
  return createFile
177
177
 
178
178
  function createFile (name) {
179
179
  const lock = toLock === null ? false : isFile(name, toLock)
180
180
  const sparse = isFile(name, 'data') || isFile(name, 'bitfield') || isFile(name, 'tree')
181
- return new RAF(name, { directory, lock, sparse, pool })
181
+ return new RAF(name, { directory, lock, sparse, pool: lock ? null : pool })
182
182
  }
183
183
 
184
184
  function isFile (name, n) {
@@ -242,14 +242,19 @@ module.exports = class Hypercore extends EventEmitter {
242
242
  async _openFromExisting (from, opts) {
243
243
  await from.opening
244
244
 
245
- this._passCapabilities(from)
246
- this.sessions = from.sessions
245
+ // includes ourself as well, so the loop below also updates us
246
+ const sessions = this.sessions
247
+
248
+ for (const s of sessions) {
249
+ s.sessions = from.sessions
250
+ s.sessions.push(s)
251
+ s._passCapabilities(from)
252
+ }
253
+
247
254
  this.storage = from.storage
248
255
  this.replicator.findingPeers += this._findingPeers
249
256
 
250
257
  ensureEncryption(this, opts)
251
-
252
- this.sessions.push(this)
253
258
  }
254
259
 
255
260
  async _openSession (key, storage, opts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.3.0",
3
+ "version": "10.3.2",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {