hypercore 10.37.24 → 10.37.25

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
@@ -10,7 +10,6 @@ const Protomux = require('protomux')
10
10
  const z32 = require('z32')
11
11
  const id = require('hypercore-id-encoding')
12
12
  const safetyCatch = require('safety-catch')
13
- const { createTracer } = require('hypertrace')
14
13
  const unslab = require('unslab')
15
14
 
16
15
  const Replicator = require('./lib/replicator')
@@ -57,7 +56,6 @@ module.exports = class Hypercore extends EventEmitter {
57
56
 
58
57
  this[promises] = true
59
58
 
60
- this.tracer = createTracer(this)
61
59
  this.storage = null
62
60
  this.crypto = opts.crypto || hypercoreCrypto
63
61
  this.core = null
@@ -290,8 +288,6 @@ module.exports = class Hypercore extends EventEmitter {
290
288
  this.writable = this._isWritable()
291
289
  this.autoClose = o.autoClose
292
290
 
293
- if (o.core) this.tracer.setParent(o.core.tracer)
294
-
295
291
  if (this.snapshotted && this.core && !this._snapshot) this._updateSnapshot()
296
292
  }
297
293
 
@@ -402,7 +398,6 @@ module.exports = class Hypercore extends EventEmitter {
402
398
  onupdate: this._oncoreupdate.bind(this),
403
399
  onconflict: this._oncoreconflict.bind(this)
404
400
  })
405
- this.tracer.setParent(this.core.tracer)
406
401
 
407
402
  if (opts.userData) {
408
403
  for (const [key, value] of Object.entries(opts.userData)) {
@@ -503,7 +498,7 @@ module.exports = class Hypercore extends EventEmitter {
503
498
  }
504
499
 
505
500
  if (this.replicator !== null) {
506
- this.replicator.destroy()
501
+ await this.replicator.destroy()
507
502
  }
508
503
 
509
504
  await this.core.close()
@@ -841,8 +836,6 @@ module.exports = class Hypercore extends EventEmitter {
841
836
  if (this.opened === false) await this.opening
842
837
  if (!isValidIndex(index)) throw ASSERTION('block index is invalid')
843
838
 
844
- this.tracer.trace('get', { index })
845
-
846
839
  if (this.closing !== null) throw SESSION_CLOSED()
847
840
  if (this._snapshot !== null && index >= this._snapshot.compatLength) throw SNAPSHOT_NOT_AVAILABLE()
848
841
 
@@ -967,8 +960,6 @@ module.exports = class Hypercore extends EventEmitter {
967
960
  async _download (range) {
968
961
  if (this.opened === false) await this.opening
969
962
 
970
- this.tracer.trace('download', { range })
971
-
972
963
  const activeRequests = (range && range.activeRequests) || this.activeRequests
973
964
 
974
965
  return this.replicator.addRange(activeRequests, range)
@@ -1011,7 +1002,6 @@ module.exports = class Hypercore extends EventEmitter {
1011
1002
  if (writable === false) throw SESSION_NOT_WRITABLE()
1012
1003
 
1013
1004
  blocks = Array.isArray(blocks) ? blocks : [blocks]
1014
- this.tracer.trace('append', { blocks })
1015
1005
 
1016
1006
  const preappend = this.encryption && this._preappend
1017
1007
 
package/lib/core.js CHANGED
@@ -13,11 +13,9 @@ const { BAD_ARGUMENT, STORAGE_EMPTY, STORAGE_CONFLICT, INVALID_OPERATION, INVALI
13
13
  const m = require('./messages')
14
14
  const Verifier = require('./verifier')
15
15
  const audit = require('./audit')
16
- const { createTracer } = require('hypertrace')
17
16
 
18
17
  module.exports = class Core {
19
18
  constructor (header, compat, crypto, oplog, bigHeader, tree, blocks, bitfield, verifier, sessions, legacy, globalCache, onupdate, onconflict) {
20
- this.tracer = createTracer(this)
21
19
  this.onupdate = onupdate
22
20
  this.onconflict = onconflict
23
21
  this.preupdate = null
package/lib/replicator.js CHANGED
@@ -31,7 +31,6 @@ const RemoteBitfield = require('./remote-bitfield')
31
31
  const { REQUEST_CANCELLED, REQUEST_TIMEOUT, INVALID_CAPABILITY, SNAPSHOT_NOT_AVAILABLE } = require('hypercore-errors')
32
32
  const m = require('./messages')
33
33
  const caps = require('./caps')
34
- const { createTracer } = require('hypertrace')
35
34
 
36
35
  const DEFAULT_MAX_INFLIGHT = [16, 512]
37
36
  const SCALE_LATENCY = 50
@@ -331,7 +330,6 @@ class RoundtripQueue {
331
330
 
332
331
  class Peer {
333
332
  constructor (replicator, protomux, channel, useSession, inflightRange) {
334
- this.tracer = createTracer(this, { parent: replicator.core.tracer })
335
333
  this.core = replicator.core
336
334
  this.replicator = replicator
337
335
  this.stream = protomux.stream
@@ -530,8 +528,6 @@ class Peer {
530
528
  }
531
529
 
532
530
  onclose (isRemote) {
533
- this.tracer.trace('onclose')
534
-
535
531
  // we might have signalled to the remote that we are done (ie not downloading) and the remote might agree on that
536
532
  // if that happens, the channel might be closed by the remote. if so just renegotiate it.
537
533
  // TODO: add a CLOSE_REASON to mux to we can make this cleaner...
@@ -682,8 +678,6 @@ class Peer {
682
678
  }
683
679
 
684
680
  async onrequest (msg) {
685
- this.tracer.trace('onrequest', msg)
686
-
687
681
  const size = this.remoteRequests.size
688
682
  this.remoteRequests.set(msg.id, msg)
689
683
 
@@ -817,8 +811,6 @@ class Peer {
817
811
  }
818
812
 
819
813
  async ondata (data) {
820
- this.tracer.trace('ondata', data)
821
-
822
814
  // always allow a fork conflict proof to be sent
823
815
  if (data.request === 0 && data.upgrade && data.upgrade.start === 0) {
824
816
  if (await this.core.checkConflict(data, this)) return
@@ -888,8 +880,6 @@ class Peer {
888
880
  }
889
881
 
890
882
  onnodata ({ request }) {
891
- this.tracer.trace('onnodata', { request })
892
-
893
883
  const req = request > 0 ? this.replicator._inflight.get(request) : null
894
884
 
895
885
  if (req === null || req.peer !== this) return
@@ -1397,8 +1387,6 @@ class Peer {
1397
1387
  return
1398
1388
  }
1399
1389
 
1400
- this.tracer.trace('send', req)
1401
-
1402
1390
  this.wireRequest.send(req)
1403
1391
  incrementTx(this.stats.wireRequest, this.replicator.stats.wireRequest)
1404
1392
  }
@@ -1416,7 +1404,6 @@ module.exports = class Replicator {
1416
1404
  onupload = noop,
1417
1405
  oninvalid = noop
1418
1406
  } = {}) {
1419
- this.tracer = createTracer(this)
1420
1407
  this.key = key
1421
1408
  this.discoveryKey = core.crypto.discoveryKey(key)
1422
1409
  this.core = core
@@ -2323,18 +2310,26 @@ module.exports = class Replicator {
2323
2310
 
2324
2311
  destroy () {
2325
2312
  this.destroyed = true
2313
+
2326
2314
  if (this._downloadingTimer) {
2327
2315
  clearTimeout(this._downloadingTimer)
2328
2316
  this._downloadingTimer = null
2329
2317
  }
2318
+
2319
+ const waiting = []
2320
+
2330
2321
  while (this.peers.length) {
2331
2322
  const peer = this.peers[this.peers.length - 1]
2332
2323
  this.detachFrom(peer.protomux)
2333
2324
  peer.channel.close() // peer is removed from array in onclose
2325
+ waiting.push(peer.channel.fullyClosed())
2334
2326
  }
2327
+
2335
2328
  for (const protomux of this._attached) {
2336
2329
  this.detachFrom(protomux)
2337
2330
  }
2331
+
2332
+ return Promise.all(waiting)
2338
2333
  }
2339
2334
 
2340
2335
  _makePeer (protomux, useSession) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.37.24",
3
+ "version": "10.37.25",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -52,7 +52,6 @@
52
52
  "hypercore-crypto": "^3.2.1",
53
53
  "hypercore-errors": "^1.2.0",
54
54
  "hypercore-id-encoding": "^1.2.0",
55
- "hypertrace": "^1.2.1",
56
55
  "is-options": "^1.0.1",
57
56
  "protomux": "^3.5.0",
58
57
  "quickbit-universal": "^2.2.0",