hypercore 11.0.14 → 11.0.16
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 -3
- package/lib/core.js +4 -0
- package/lib/session-state.js +4 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -528,9 +528,7 @@ class Hypercore extends EventEmitter {
|
|
|
528
528
|
}
|
|
529
529
|
|
|
530
530
|
get signedLength () {
|
|
531
|
-
|
|
532
|
-
if (this.state === this.core.state) return this.core.state.length
|
|
533
|
-
return this.state.flushedLength()
|
|
531
|
+
return this.opened === false ? 0 : this.state.signedLength()
|
|
534
532
|
}
|
|
535
533
|
|
|
536
534
|
/**
|
package/lib/core.js
CHANGED
|
@@ -150,6 +150,10 @@ module.exports = class Core {
|
|
|
150
150
|
overwrite = true
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
if (!header && (opts.discoveryKey && !(opts.key || opts.manifest))) {
|
|
154
|
+
throw STORAGE_EMPTY('No Hypercore is stored here')
|
|
155
|
+
}
|
|
156
|
+
|
|
153
157
|
if (!header || overwrite) {
|
|
154
158
|
if (!createIfMissing) {
|
|
155
159
|
throw STORAGE_EMPTY('No Hypercore is stored here')
|
package/lib/session-state.js
CHANGED
|
@@ -90,6 +90,10 @@ module.exports = class SessionState {
|
|
|
90
90
|
return 0
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
signedLength () {
|
|
94
|
+
return Math.min(this.flushedLength(), this.core.state.length)
|
|
95
|
+
}
|
|
96
|
+
|
|
93
97
|
unref () {
|
|
94
98
|
if (--this.active > 0) return
|
|
95
99
|
this.close().catch(noop) // technically async, but only for the last db session
|