blind-peer 2.7.15 → 2.7.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/bin.js +23 -1
- package/package.json +1 -1
package/bin.js
CHANGED
|
@@ -20,7 +20,7 @@ const cmd = command('blind-peer',
|
|
|
20
20
|
flag('--storage|-s [path]', 'Storage path, defaults to ./blind-peer'),
|
|
21
21
|
flag('--port|-p [int]', 'DHT Port to try to bind to. Only relevant when that port is not firewalled. (defaults to a random port)'),
|
|
22
22
|
flag('--trusted-peer|-t [trusted-peer]', 'Public key of a trusted peer (allowed to set announce: true). Can be more than 1.').multiple(),
|
|
23
|
-
flag('--debug|-d', 'Enable debug mode (more logs)')
|
|
23
|
+
flag('--debug|-d', 'Enable debug mode (more logs)'),
|
|
24
24
|
flag(`--max-storage|-m [int]', 'Max storage usage, in Mb (defaults to ${DEFAULT_STORAGE_LIMIT_MB})`),
|
|
25
25
|
flag('--autodiscovery-rpc-key [autodiscovery-rpc-key]', 'Public key where the autodiscovery service is listening. When set, the autodiscovery-seed must also be set. Can be hex or z32.'),
|
|
26
26
|
flag('--autodiscovery-seed [autodiscovery-seed]', '64-byte seed used to authenticate to the autodiscovery service. Can be hex or z32.'),
|
|
@@ -28,6 +28,7 @@ const cmd = command('blind-peer',
|
|
|
28
28
|
flag('--scraper-public-key [scraper-public-key]', 'Public key of a dht-prometheus scraper. Can be hex or z32.'),
|
|
29
29
|
flag('--scraper-secret [scraper-secret]', 'Secret of the dht-prometheus scraper. Can be hex or z32.'),
|
|
30
30
|
flag('--scraper-alias [scraper-alias]', '(optional) Alias with which to register to the scraper'),
|
|
31
|
+
flag('--log-streams', '(Temporary, Advanced): enable debug logs on the UDX streams managed by the dht'),
|
|
31
32
|
flag('--repl [repl]', 'Expose a repl-swarm at the passed-in seed (32 bytes in hex or z32 notation). Use for debugging only.'),
|
|
32
33
|
async function ({ flags }) {
|
|
33
34
|
const debug = flags.debug
|
|
@@ -37,6 +38,8 @@ const cmd = command('blind-peer',
|
|
|
37
38
|
})
|
|
38
39
|
logger.info('Starting blind peer')
|
|
39
40
|
|
|
41
|
+
const logStreams = flags.logStreams
|
|
42
|
+
|
|
40
43
|
const storage = flags.storage || 'blind-peer'
|
|
41
44
|
const port = flags.port ? parseInt(flags.port) : null
|
|
42
45
|
|
|
@@ -137,6 +140,25 @@ const cmd = command('blind-peer',
|
|
|
137
140
|
})
|
|
138
141
|
}
|
|
139
142
|
|
|
143
|
+
if (logStreams) {
|
|
144
|
+
logger.warn('Advanced debugging option log-streams enabled')
|
|
145
|
+
setInterval(() => {
|
|
146
|
+
try {
|
|
147
|
+
let nrBigStreams = 0
|
|
148
|
+
for (const stream of blindPeer.swarm.dht.rawStreams) {
|
|
149
|
+
const pendingWrites = stream._wreqs.length - stream._wfree.length
|
|
150
|
+
if (pendingWrites >= 100) {
|
|
151
|
+
nrBigStreams++
|
|
152
|
+
console.warn(`Stream ${stream.id} (remote id: ${stream.remoteId}) has ${pendingWrites} pending writes:\nStream JSON: ${JSON.stringify(stream.toJSON(), null, 1)}\nSocket json: ${stream.socket ? JSON.stringify(stream.socket.toJSON(), null, 1) : 'none'}\nhex streamhandle: ${b4a.toString(stream._handle, 'hex')}\nhex socket handle: ${stream.socket ? b4a.toString(stream.socket._handle, 'hex') : 'none'}`)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (nrBigStreams > 0) console.warn(`Total streams with many pending writes: ${nrBigStreams}`)
|
|
156
|
+
} catch (e) { // we don't want to crash the process with our debugging
|
|
157
|
+
console.warn(`logStreams errored unexpectedly: ${e.stack}`)
|
|
158
|
+
}
|
|
159
|
+
}, 30_000)
|
|
160
|
+
}
|
|
161
|
+
|
|
140
162
|
await blindPeer.listen()
|
|
141
163
|
|
|
142
164
|
logger.info(`Blind peer listening, local address is ${blindPeer.swarm.dht.localAddress().host}:${blindPeer.swarm.dht.localAddress().port}`)
|