@optimystic/db-p2p 0.24.0 → 0.24.2
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/dist/src/cluster/service.d.ts +8 -0
- package/dist/src/cluster/service.d.ts.map +1 -1
- package/dist/src/cluster/service.js +16 -4
- package/dist/src/cluster/service.js.map +1 -1
- package/dist/src/cohort-topic/host.js +34 -11
- package/dist/src/cohort-topic/host.js.map +1 -1
- package/dist/src/cohort-topic/stream-util.d.ts +25 -11
- package/dist/src/cohort-topic/stream-util.d.ts.map +1 -1
- package/dist/src/cohort-topic/stream-util.js +31 -19
- package/dist/src/cohort-topic/stream-util.js.map +1 -1
- package/dist/src/libp2p-key-network.d.ts +68 -0
- package/dist/src/libp2p-key-network.d.ts.map +1 -1
- package/dist/src/libp2p-key-network.js +123 -14
- package/dist/src/libp2p-key-network.js.map +1 -1
- package/dist/src/libp2p-node-base.d.ts.map +1 -1
- package/dist/src/libp2p-node-base.js +8 -5
- package/dist/src/libp2p-node-base.js.map +1 -1
- package/dist/src/logger.d.ts +2 -2
- package/dist/src/logger.js +2 -2
- package/dist/src/matchmaking/query-transport.js +3 -3
- package/dist/src/matchmaking/query-transport.js.map +1 -1
- package/dist/src/peer-address-book.d.ts +69 -0
- package/dist/src/peer-address-book.d.ts.map +1 -1
- package/dist/src/peer-address-book.js +110 -15
- package/dist/src/peer-address-book.js.map +1 -1
- package/dist/src/reactivity/notify-transport.d.ts +4 -4
- package/dist/src/reactivity/notify-transport.js +6 -6
- package/dist/src/reactivity/notify-transport.js.map +1 -1
- package/dist/src/reactivity/push-state-gossip.js +2 -2
- package/dist/src/reactivity/push-state-gossip.js.map +1 -1
- package/dist/src/reactivity/recover-transport.d.ts +6 -2
- package/dist/src/reactivity/recover-transport.d.ts.map +1 -1
- package/dist/src/reactivity/recover-transport.js +7 -3
- package/dist/src/reactivity/recover-transport.js.map +1 -1
- package/dist/src/repo/service.d.ts +6 -0
- package/dist/src/repo/service.d.ts.map +1 -1
- package/dist/src/repo/service.js +12 -2
- package/dist/src/repo/service.js.map +1 -1
- package/dist/src/routing/libp2p-known-peers.d.ts.map +1 -1
- package/dist/src/routing/libp2p-known-peers.js +5 -0
- package/dist/src/routing/libp2p-known-peers.js.map +1 -1
- package/dist/src/testing/cohort-topic-mesh-harness.d.ts +13 -6
- package/dist/src/testing/cohort-topic-mesh-harness.d.ts.map +1 -1
- package/dist/src/testing/cohort-topic-mesh-harness.js +15 -6
- package/dist/src/testing/cohort-topic-mesh-harness.js.map +1 -1
- package/package.json +3 -3
- package/src/cluster/service.ts +305 -293
- package/src/cohort-topic/host.ts +2932 -2901
- package/src/cohort-topic/stream-util.ts +147 -135
- package/src/libp2p-key-network.ts +1235 -1120
- package/src/libp2p-node-base.ts +1678 -1675
- package/src/logger.ts +27 -27
- package/src/matchmaking/query-transport.ts +492 -492
- package/src/peer-address-book.ts +266 -149
- package/src/reactivity/notify-transport.ts +144 -144
- package/src/reactivity/push-state-gossip.ts +291 -291
- package/src/reactivity/recover-transport.ts +412 -408
- package/src/repo/service.ts +323 -313
- package/src/routing/libp2p-known-peers.ts +31 -26
- package/src/testing/cohort-topic-mesh-harness.ts +673 -663
package/src/logger.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import debug from 'debug'
|
|
2
|
-
|
|
3
|
-
const BASE_NAMESPACE = 'optimystic:db-p2p'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Build a `debug` logger under `optimystic:db-p2p:<subNamespace>`, optionally suffixed with the
|
|
7
|
-
* owning node's peer id (`:<first 12 chars>`) so lines from several nodes sharing one process —
|
|
8
|
-
* every integration test — are attributable. Omit `peerId` and the namespace is byte-for-byte the
|
|
9
|
-
* un-suffixed one, so callers that don't know their peer id are unaffected.
|
|
10
|
-
*
|
|
11
|
-
* NOTE: 12 chars matches the truncation the rest of this package already uses in log payloads, but
|
|
12
|
-
* every Ed25519 peer id starts with the constant `12D3KooW`, so only ~4 base58 characters actually
|
|
13
|
-
* distinguish nodes (~11M combinations — ample for the handful of nodes a test process runs).
|
|
14
|
-
* Widen this only if a run ever needs to match a namespace against a full peer id.
|
|
15
|
-
*
|
|
16
|
-
* NOTE: only
|
|
17
|
-
*
|
|
18
|
-
* still log under a flat namespace. Thread a peer id through any of them if a future diagnosis
|
|
19
|
-
* needs per-node attribution from that subsystem — the mechanism is already here.
|
|
20
|
-
*/
|
|
21
|
-
export function createLogger(subNamespace: string, peerId?: string): debug.Debugger {
|
|
22
|
-
const suffix = peerId ? `:${peerId.substring(0, 12)}` : ''
|
|
23
|
-
return debug(`${BASE_NAMESPACE}:${subNamespace}${suffix}`)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const verbose = typeof process !== 'undefined'
|
|
27
|
-
&& (process.env.OPTIMYSTIC_VERBOSE === '1' || process.env.OPTIMYSTIC_VERBOSE === 'true');
|
|
1
|
+
import debug from 'debug'
|
|
2
|
+
|
|
3
|
+
const BASE_NAMESPACE = 'optimystic:db-p2p'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Build a `debug` logger under `optimystic:db-p2p:<subNamespace>`, optionally suffixed with the
|
|
7
|
+
* owning node's peer id (`:<first 12 chars>`) so lines from several nodes sharing one process —
|
|
8
|
+
* every integration test — are attributable. Omit `peerId` and the namespace is byte-for-byte the
|
|
9
|
+
* un-suffixed one, so callers that don't know their peer id are unaffected.
|
|
10
|
+
*
|
|
11
|
+
* NOTE: 12 chars matches the truncation the rest of this package already uses in log payloads, but
|
|
12
|
+
* every Ed25519 peer id starts with the constant `12D3KooW`, so only ~4 base58 characters actually
|
|
13
|
+
* distinguish nodes (~11M combinations — ample for the handful of nodes a test process runs).
|
|
14
|
+
* Widen this only if a run ever needs to match a namespace against a full peer id.
|
|
15
|
+
*
|
|
16
|
+
* NOTE: only a few call sites pass a peer id today (`Libp2pKeyPeerNetwork`, `CoordinatorRepo`, and
|
|
17
|
+
* the three `peer-address-book` sinks); the package's other ~30 `createLogger` call sites
|
|
18
|
+
* still log under a flat namespace. Thread a peer id through any of them if a future diagnosis
|
|
19
|
+
* needs per-node attribution from that subsystem — the mechanism is already here.
|
|
20
|
+
*/
|
|
21
|
+
export function createLogger(subNamespace: string, peerId?: string): debug.Debugger {
|
|
22
|
+
const suffix = peerId ? `:${peerId.substring(0, 12)}` : ''
|
|
23
|
+
return debug(`${BASE_NAMESPACE}:${subNamespace}${suffix}`)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const verbose = typeof process !== 'undefined'
|
|
27
|
+
&& (process.env.OPTIMYSTIC_VERBOSE === '1' || process.env.OPTIMYSTIC_VERBOSE === 'true');
|