hypercore 11.0.39 → 11.0.41
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 +1 -0
- package/lib/core.js +4 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1081,6 +1081,7 @@ function initOnce (session, storage, key, opts) {
|
|
|
1081
1081
|
if (key === null) key = opts.key || null
|
|
1082
1082
|
|
|
1083
1083
|
session.core = new Core(Hypercore.defaultStorage(storage), {
|
|
1084
|
+
preopen: opts.preopen,
|
|
1084
1085
|
eagerUpgrade: true,
|
|
1085
1086
|
notDownloadingLinger: opts.notDownloadingLinger,
|
|
1086
1087
|
allowFork: opts.allowFork !== false,
|
package/lib/core.js
CHANGED
|
@@ -99,7 +99,7 @@ module.exports = class Core {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
checkIfIdle () {
|
|
102
|
-
if (this.destroyed === true || this.hasSession() === true) return
|
|
102
|
+
if (!this.opened || this.destroyed === true || this.hasSession() === true) return
|
|
103
103
|
if (this.replicator.idle() === false) return
|
|
104
104
|
if (this.state === null || this.state.mutex.idle() === false) return
|
|
105
105
|
this.onidle()
|
|
@@ -123,9 +123,12 @@ module.exports = class Core {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
this.opened = true
|
|
126
|
+
this.checkIfIdle()
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
async _tryOpen (opts) {
|
|
130
|
+
if (opts.preopen) await opts.preopen // just a hook to allow exclusive access here...
|
|
131
|
+
|
|
129
132
|
let storage = await this.db.resume(this.discoveryKey)
|
|
130
133
|
|
|
131
134
|
let overwrite = opts.overwrite === true
|