hypercore 10.37.15 → 10.37.17

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 CHANGED
@@ -270,6 +270,14 @@ module.exports = class Hypercore extends EventEmitter {
270
270
  this.writable = this._isWritable()
271
271
  }
272
272
 
273
+ setActive (bool) {
274
+ const active = !!bool
275
+ if (active === this._active) return
276
+ this._active = active
277
+ if (!this.opened || this.closing) return
278
+ this.replicator.updateActivity(this._active ? 1 : -1)
279
+ }
280
+
273
281
  _passCapabilities (o) {
274
282
  if (!this.keyPair) this.keyPair = o.keyPair
275
283
  this.crypto = o.crypto
package/lib/core.js CHANGED
@@ -107,7 +107,7 @@ module.exports = class Core {
107
107
  external: null,
108
108
  key: opts.key || (compat ? manifest.signers[0].publicKey : Verifier.manifestHash(manifest)),
109
109
  manifest,
110
- keyPair,
110
+ keyPair: keyPair ? { publicKey: keyPair.publicKey, secretKey: keyPair.secretKey || null } : null,
111
111
  userData: [],
112
112
  tree: {
113
113
  fork: 0,
@@ -131,6 +131,11 @@ module.exports = class Core {
131
131
  header.tree.rootHash = unslab(header.tree.rootHash)
132
132
  header.tree.signature = unslab(header.tree.signature)
133
133
 
134
+ if (header.keyPair) {
135
+ header.keyPair.publicKey = unslab(header.keyPair.publicKey)
136
+ header.keyPair.secretKey = unslab(header.keyPair.secretKey)
137
+ }
138
+
134
139
  if (opts.manifest) {
135
140
  // if we provide a manifest and no key, verify that the stored key is the same
136
141
  if (!opts.key && !Verifier.isValidManifest(header.key, Verifier.createManifest(opts.manifest))) {
@@ -204,6 +209,10 @@ module.exports = class Core {
204
209
  }
205
210
  }
206
211
 
212
+ for (const entry of header.userData) {
213
+ entry.value = unslab(entry.value)
214
+ }
215
+
207
216
  return new this(header, compat, crypto, oplog, bigHeader, tree, blocks, bitfield, verifier, opts.sessions || [], legacy, opts.globalCache || null, opts.onupdate || noop, opts.onconflict || noop)
208
217
  }
209
218
 
@@ -1022,6 +1031,8 @@ function addReorgHint (list, tree, batch) {
1022
1031
  }
1023
1032
 
1024
1033
  function updateUserData (list, key, value) {
1034
+ value = unslab(value)
1035
+
1025
1036
  for (let i = 0; i < list.length; i++) {
1026
1037
  if (list[i].key === key) {
1027
1038
  if (value) list[i].value = value
package/lib/replicator.js CHANGED
@@ -1301,7 +1301,6 @@ class Peer {
1301
1301
  if (this._remoteHasBlock(index) === false) continue
1302
1302
 
1303
1303
  const req = this._makeRequest(false, 0, 0)
1304
- if (req === null) continue
1305
1304
 
1306
1305
  req.hash = { index: 2 * index, nodes: f.batch.want.nodes }
1307
1306
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.37.15",
3
+ "version": "10.37.17",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {