blind-peer 2.9.3 → 2.9.5
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/bare-bin.js +3 -0
- package/bin.js +6 -1
- package/index.js +26 -8
- package/package.json +24 -8
package/bare-bin.js
ADDED
package/bin.js
CHANGED
|
@@ -10,6 +10,7 @@ const byteSize = require('tiny-byte-size')
|
|
|
10
10
|
const pino = require('pino')
|
|
11
11
|
const b4a = require('b4a')
|
|
12
12
|
const hypCrypto = require('hypercore-crypto')
|
|
13
|
+
const { version: ownVersion } = require('./package.json')
|
|
13
14
|
|
|
14
15
|
const BlindPeer = require('.')
|
|
15
16
|
|
|
@@ -131,6 +132,9 @@ const cmd = command(
|
|
|
131
132
|
blindPeer.on('announce-core', (core) => {
|
|
132
133
|
logger.info(`Started announcing core ${coreToInfo(core, true)}`)
|
|
133
134
|
})
|
|
135
|
+
blindPeer.on('announced-initial-cores', () => {
|
|
136
|
+
logger.info(`Announced all initial cores`)
|
|
137
|
+
})
|
|
134
138
|
blindPeer.on('core-downloaded', (core) => {
|
|
135
139
|
logger.info(`Announced core fully downloaded: ${coreToInfo(core, true)}`)
|
|
136
140
|
})
|
|
@@ -284,7 +288,8 @@ const cmd = command(
|
|
|
284
288
|
scraperPublicKey,
|
|
285
289
|
prometheusAlias,
|
|
286
290
|
scraperSecret,
|
|
287
|
-
prometheusServiceName: SERVICE_NAME
|
|
291
|
+
prometheusServiceName: SERVICE_NAME,
|
|
292
|
+
version: ownVersion
|
|
288
293
|
})
|
|
289
294
|
|
|
290
295
|
blindPeer.registerMetrics(instrumentation.promClient)
|
package/index.js
CHANGED
|
@@ -187,7 +187,17 @@ class WakeupHandler {
|
|
|
187
187
|
class BlindPeer extends ReadyResource {
|
|
188
188
|
constructor(
|
|
189
189
|
rocks,
|
|
190
|
-
{
|
|
190
|
+
{
|
|
191
|
+
swarm,
|
|
192
|
+
store,
|
|
193
|
+
wakeup,
|
|
194
|
+
maxBytes = 100_000_000_000,
|
|
195
|
+
enableGc = true,
|
|
196
|
+
trustedPubKeys,
|
|
197
|
+
port,
|
|
198
|
+
announcingInterval = 100,
|
|
199
|
+
wakeupGcTickTime = null
|
|
200
|
+
} = {}
|
|
191
201
|
) {
|
|
192
202
|
super()
|
|
193
203
|
|
|
@@ -195,10 +205,11 @@ class BlindPeer extends ReadyResource {
|
|
|
195
205
|
this.store = store || new Corestore(this.rocks, { active: false })
|
|
196
206
|
this.swarm = swarm || null
|
|
197
207
|
this._port = port || 0
|
|
208
|
+
this.announcingInterval = announcingInterval
|
|
198
209
|
this.trustedPubKeys = new Set()
|
|
199
210
|
for (const k of trustedPubKeys || []) this.addTrustedPubKey(k)
|
|
200
211
|
|
|
201
|
-
this.wakeup = wakeup || new Wakeup(this._onwakeup.bind(this))
|
|
212
|
+
this.wakeup = wakeup || new Wakeup(this._onwakeup.bind(this), { gcTickTime: wakeupGcTickTime })
|
|
202
213
|
this.ownsWakeup = !wakeup
|
|
203
214
|
this.ownsSwarm = !swarm
|
|
204
215
|
this.ownsStore = !store
|
|
@@ -266,12 +277,7 @@ class BlindPeer extends ReadyResource {
|
|
|
266
277
|
}
|
|
267
278
|
this.swarm.on('connection', this._onconnection.bind(this))
|
|
268
279
|
|
|
269
|
-
|
|
270
|
-
for await (const record of this.db.createAnnouncingCoresStream()) {
|
|
271
|
-
announceProms.push(this._announceCore(record.key))
|
|
272
|
-
}
|
|
273
|
-
await Promise.all(announceProms)
|
|
274
|
-
|
|
280
|
+
this._announceCores().catch(safetyCatch) // announcing cores asynchronously
|
|
275
281
|
this.flushInterval = setInterval(this.flush.bind(this), 10_000)
|
|
276
282
|
}
|
|
277
283
|
|
|
@@ -442,6 +448,18 @@ class BlindPeer extends ReadyResource {
|
|
|
442
448
|
stream.on('close', () => core.close().catch(safetyCatch))
|
|
443
449
|
}
|
|
444
450
|
|
|
451
|
+
async _announceCores() {
|
|
452
|
+
for await (const record of this.db.createAnnouncingCoresStream()) {
|
|
453
|
+
if (this.closing) return
|
|
454
|
+
await this._announceCore(record.key)
|
|
455
|
+
if (this.closing) return
|
|
456
|
+
await new Promise((resolve) => setTimeout(resolve, this.announcingInterval))
|
|
457
|
+
if (this.closing) return
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
this.emit('announced-initial-cores')
|
|
461
|
+
}
|
|
462
|
+
|
|
445
463
|
async _announceCore(key) {
|
|
446
464
|
const coreId = IdEnc.normalize(key)
|
|
447
465
|
if (this.announcedCores.has(coreId)) return
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blind-peer",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.5",
|
|
4
4
|
"description": "Blind peers help keep hypercores available",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"blind-peer": "bin.js"
|
|
7
|
+
"blind-peer": "bin.js",
|
|
8
|
+
"blind-peer-bare": "bare-bin.js"
|
|
8
9
|
},
|
|
9
10
|
"dependencies": {
|
|
10
11
|
"autobase": "^7.0.18",
|
|
@@ -14,7 +15,7 @@
|
|
|
14
15
|
"compact-encoding": "^2.16.0",
|
|
15
16
|
"corestore": "^7.4.4",
|
|
16
17
|
"graceful-goodbye": "^1.3.3",
|
|
17
|
-
"hyper-instrument": "^
|
|
18
|
+
"hyper-instrument": "^3.0.0",
|
|
18
19
|
"hypercore": "^11.0.12",
|
|
19
20
|
"hypercore-crypto": "^3.5.0",
|
|
20
21
|
"hypercore-id-encoding": "^1.3.0",
|
|
@@ -23,8 +24,9 @@
|
|
|
23
24
|
"hyperswarm": "^4.13.1",
|
|
24
25
|
"paparam": "^1.8.0",
|
|
25
26
|
"pino": "^9.6.0",
|
|
27
|
+
"pino-bare": "^0.0.1",
|
|
26
28
|
"protomux-rpc": "^1.7.1",
|
|
27
|
-
"protomux-wakeup": "^2.
|
|
29
|
+
"protomux-wakeup": "^2.9.0",
|
|
28
30
|
"ready-resource": "^1.1.2",
|
|
29
31
|
"repl-swarm": "^2.3.0",
|
|
30
32
|
"rocksdb-native": "^3.1.6",
|
|
@@ -33,6 +35,8 @@
|
|
|
33
35
|
"tiny-byte-size": "^1.1.0"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
38
|
+
"bare-events": "^2.8.2",
|
|
39
|
+
"bare-process": "^4.2.2",
|
|
36
40
|
"blind-peering": "^1.13.0",
|
|
37
41
|
"brittle": "^3.7.0",
|
|
38
42
|
"debounceify": "^1.1.0",
|
|
@@ -40,7 +44,8 @@
|
|
|
40
44
|
"prettier": "^3.6.2",
|
|
41
45
|
"prettier-config-holepunch": "^2.0.0",
|
|
42
46
|
"prom-client": "^15.1.3",
|
|
43
|
-
"test-tmp": "^1.3.0"
|
|
47
|
+
"test-tmp": "^1.3.0",
|
|
48
|
+
"which-runtime": "^1.3.2"
|
|
44
49
|
},
|
|
45
50
|
"files": [
|
|
46
51
|
"bin.js",
|
|
@@ -49,8 +54,9 @@
|
|
|
49
54
|
],
|
|
50
55
|
"scripts": {
|
|
51
56
|
"format": "prettier --write .",
|
|
52
|
-
"
|
|
53
|
-
"test
|
|
57
|
+
"format:check": "prettier --check .",
|
|
58
|
+
"test": "npm run format:check && brittle test/*.js",
|
|
59
|
+
"test:bare": "bare test/test.js"
|
|
54
60
|
},
|
|
55
61
|
"repository": {
|
|
56
62
|
"type": "git",
|
|
@@ -61,5 +67,15 @@
|
|
|
61
67
|
"bugs": {
|
|
62
68
|
"url": "https://github.com/holepunchto/blind-peer/issues"
|
|
63
69
|
},
|
|
64
|
-
"homepage": "https://github.com/holepunchto/blind-peer"
|
|
70
|
+
"homepage": "https://github.com/holepunchto/blind-peer",
|
|
71
|
+
"imports": {
|
|
72
|
+
"pino": {
|
|
73
|
+
"bare": "pino-bare",
|
|
74
|
+
"default": "pino"
|
|
75
|
+
},
|
|
76
|
+
"events": {
|
|
77
|
+
"bare": "bare-events",
|
|
78
|
+
"default": "events"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
65
81
|
}
|