hypercore 10.25.1 → 10.25.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.
- package/index.js +5 -0
- package/lib/batch.js +3 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -248,6 +248,11 @@ module.exports = class Hypercore extends EventEmitter {
|
|
|
248
248
|
return s
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
async setEncryptionKey (key) {
|
|
252
|
+
if (!this.opened) await this.opening
|
|
253
|
+
this.encryption = key ? new BlockEncryption(key, this.key) : null
|
|
254
|
+
}
|
|
255
|
+
|
|
251
256
|
setKeyPair (keyPair) {
|
|
252
257
|
this.keyPair = keyPair
|
|
253
258
|
this.writable = this._isWritable()
|
package/lib/batch.js
CHANGED
|
@@ -321,7 +321,10 @@ module.exports = class HypercoreBatch extends EventEmitter {
|
|
|
321
321
|
this._sessionByteLength = info.byteLength
|
|
322
322
|
this._sessionBatch = this.session.createTreeBatch()
|
|
323
323
|
|
|
324
|
+
const same = this._appends === this._appendsActual
|
|
325
|
+
|
|
324
326
|
this._appends = this._appends.slice(flushingLength)
|
|
327
|
+
this._appendsActual = same ? this._appends : this._appendsActual.slice(flushingLength)
|
|
325
328
|
this._byteLength -= delta
|
|
326
329
|
|
|
327
330
|
this.emit('flush')
|