From 72cf1eb7b5fd965047a569df5ffdfcd8b781cd6f Mon Sep 17 00:00:00 2001 From: HDegroote <75906619+HDegroote@users.noreply.github.com> Date: Wed, 2 Oct 2024 11:55:41 +0200 Subject: [PATCH] Rm hypertrace (#574) * Rm hypertrace * Also rm from replicator * Lint (blank line) --- index.js | 10 ---------- lib/core.js | 2 -- lib/replicator.js | 13 ------------- package.json | 1 - 4 files changed, 26 deletions(-) diff --git a/index.js b/index.js index 0b1b0890..bbb0ec3b 100644 --- a/index.js +++ b/index.js @@ -10,7 +10,6 @@ const Protomux = require('protomux') const z32 = require('z32') const id = require('hypercore-id-encoding') const safetyCatch = require('safety-catch') -const { createTracer } = require('hypertrace') const unslab = require('unslab') const Replicator = require('./lib/replicator') @@ -57,7 +56,6 @@ module.exports = class Hypercore extends EventEmitter { this[promises] = true - this.tracer = createTracer(this) this.storage = null this.crypto = opts.crypto || hypercoreCrypto this.core = null @@ -290,8 +288,6 @@ module.exports = class Hypercore extends EventEmitter { this.writable = this._isWritable() this.autoClose = o.autoClose - if (o.core) this.tracer.setParent(o.core.tracer) - if (this.snapshotted && this.core && !this._snapshot) this._updateSnapshot() } @@ -402,7 +398,6 @@ module.exports = class Hypercore extends EventEmitter { onupdate: this._oncoreupdate.bind(this), onconflict: this._oncoreconflict.bind(this) }) - this.tracer.setParent(this.core.tracer) if (opts.userData) { for (const [key, value] of Object.entries(opts.userData)) { @@ -841,8 +836,6 @@ module.exports = class Hypercore extends EventEmitter { if (this.opened === false) await this.opening if (!isValidIndex(index)) throw ASSERTION('block index is invalid') - this.tracer.trace('get', { index }) - if (this.closing !== null) throw SESSION_CLOSED() if (this._snapshot !== null && index >= this._snapshot.compatLength) throw SNAPSHOT_NOT_AVAILABLE() @@ -967,8 +960,6 @@ module.exports = class Hypercore extends EventEmitter { async _download (range) { if (this.opened === false) await this.opening - this.tracer.trace('download', { range }) - const activeRequests = (range && range.activeRequests) || this.activeRequests return this.replicator.addRange(activeRequests, range) @@ -1011,7 +1002,6 @@ module.exports = class Hypercore extends EventEmitter { if (writable === false) throw SESSION_NOT_WRITABLE() blocks = Array.isArray(blocks) ? blocks : [blocks] - this.tracer.trace('append', { blocks }) const preappend = this.encryption && this._preappend diff --git a/lib/core.js b/lib/core.js index 7e54d363..37d4e0c5 100644 --- a/lib/core.js +++ b/lib/core.js @@ -13,11 +13,9 @@ const { BAD_ARGUMENT, STORAGE_EMPTY, STORAGE_CONFLICT, INVALID_OPERATION, INVALI const m = require('./messages') const Verifier = require('./verifier') const audit = require('./audit') -const { createTracer } = require('hypertrace') module.exports = class Core { constructor (header, compat, crypto, oplog, bigHeader, tree, blocks, bitfield, verifier, sessions, legacy, globalCache, onupdate, onconflict) { - this.tracer = createTracer(this) this.onupdate = onupdate this.onconflict = onconflict this.preupdate = null diff --git a/lib/replicator.js b/lib/replicator.js index 4144754a..f65367f9 100644 --- a/lib/replicator.js +++ b/lib/replicator.js @@ -31,7 +31,6 @@ const RemoteBitfield = require('./remote-bitfield') const { REQUEST_CANCELLED, REQUEST_TIMEOUT, INVALID_CAPABILITY, SNAPSHOT_NOT_AVAILABLE } = require('hypercore-errors') const m = require('./messages') const caps = require('./caps') -const { createTracer } = require('hypertrace') const DEFAULT_MAX_INFLIGHT = [16, 512] const SCALE_LATENCY = 50 @@ -331,7 +330,6 @@ class RoundtripQueue { class Peer { constructor (replicator, protomux, channel, useSession, inflightRange) { - this.tracer = createTracer(this, { parent: replicator.core.tracer }) this.core = replicator.core this.replicator = replicator this.stream = protomux.stream @@ -530,8 +528,6 @@ class Peer { } onclose (isRemote) { - this.tracer.trace('onclose') - // we might have signalled to the remote that we are done (ie not downloading) and the remote might agree on that // if that happens, the channel might be closed by the remote. if so just renegotiate it. // TODO: add a CLOSE_REASON to mux to we can make this cleaner... @@ -682,8 +678,6 @@ class Peer { } async onrequest (msg) { - this.tracer.trace('onrequest', msg) - const size = this.remoteRequests.size this.remoteRequests.set(msg.id, msg) @@ -817,8 +811,6 @@ class Peer { } async ondata (data) { - this.tracer.trace('ondata', data) - // always allow a fork conflict proof to be sent if (data.request === 0 && data.upgrade && data.upgrade.start === 0) { if (await this.core.checkConflict(data, this)) return @@ -888,8 +880,6 @@ class Peer { } onnodata ({ request }) { - this.tracer.trace('onnodata', { request }) - const req = request > 0 ? this.replicator._inflight.get(request) : null if (req === null || req.peer !== this) return @@ -1397,8 +1387,6 @@ class Peer { return } - this.tracer.trace('send', req) - this.wireRequest.send(req) incrementTx(this.stats.wireRequest, this.replicator.stats.wireRequest) } @@ -1416,7 +1404,6 @@ module.exports = class Replicator { onupload = noop, oninvalid = noop } = {}) { - this.tracer = createTracer(this) this.key = key this.discoveryKey = core.crypto.discoveryKey(key) this.core = core diff --git a/package.json b/package.json index a69f6f1e..a2366c1f 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,6 @@ "hypercore-crypto": "^3.2.1", "hypercore-errors": "^1.2.0", "hypercore-id-encoding": "^1.2.0", - "hypertrace": "^1.2.1", "is-options": "^1.0.1", "protomux": "^3.5.0", "quickbit-universal": "^2.2.0",