@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.
Files changed (60) hide show
  1. package/dist/src/cluster/service.d.ts +8 -0
  2. package/dist/src/cluster/service.d.ts.map +1 -1
  3. package/dist/src/cluster/service.js +16 -4
  4. package/dist/src/cluster/service.js.map +1 -1
  5. package/dist/src/cohort-topic/host.js +34 -11
  6. package/dist/src/cohort-topic/host.js.map +1 -1
  7. package/dist/src/cohort-topic/stream-util.d.ts +25 -11
  8. package/dist/src/cohort-topic/stream-util.d.ts.map +1 -1
  9. package/dist/src/cohort-topic/stream-util.js +31 -19
  10. package/dist/src/cohort-topic/stream-util.js.map +1 -1
  11. package/dist/src/libp2p-key-network.d.ts +68 -0
  12. package/dist/src/libp2p-key-network.d.ts.map +1 -1
  13. package/dist/src/libp2p-key-network.js +123 -14
  14. package/dist/src/libp2p-key-network.js.map +1 -1
  15. package/dist/src/libp2p-node-base.d.ts.map +1 -1
  16. package/dist/src/libp2p-node-base.js +8 -5
  17. package/dist/src/libp2p-node-base.js.map +1 -1
  18. package/dist/src/logger.d.ts +2 -2
  19. package/dist/src/logger.js +2 -2
  20. package/dist/src/matchmaking/query-transport.js +3 -3
  21. package/dist/src/matchmaking/query-transport.js.map +1 -1
  22. package/dist/src/peer-address-book.d.ts +69 -0
  23. package/dist/src/peer-address-book.d.ts.map +1 -1
  24. package/dist/src/peer-address-book.js +110 -15
  25. package/dist/src/peer-address-book.js.map +1 -1
  26. package/dist/src/reactivity/notify-transport.d.ts +4 -4
  27. package/dist/src/reactivity/notify-transport.js +6 -6
  28. package/dist/src/reactivity/notify-transport.js.map +1 -1
  29. package/dist/src/reactivity/push-state-gossip.js +2 -2
  30. package/dist/src/reactivity/push-state-gossip.js.map +1 -1
  31. package/dist/src/reactivity/recover-transport.d.ts +6 -2
  32. package/dist/src/reactivity/recover-transport.d.ts.map +1 -1
  33. package/dist/src/reactivity/recover-transport.js +7 -3
  34. package/dist/src/reactivity/recover-transport.js.map +1 -1
  35. package/dist/src/repo/service.d.ts +6 -0
  36. package/dist/src/repo/service.d.ts.map +1 -1
  37. package/dist/src/repo/service.js +12 -2
  38. package/dist/src/repo/service.js.map +1 -1
  39. package/dist/src/routing/libp2p-known-peers.d.ts.map +1 -1
  40. package/dist/src/routing/libp2p-known-peers.js +5 -0
  41. package/dist/src/routing/libp2p-known-peers.js.map +1 -1
  42. package/dist/src/testing/cohort-topic-mesh-harness.d.ts +13 -6
  43. package/dist/src/testing/cohort-topic-mesh-harness.d.ts.map +1 -1
  44. package/dist/src/testing/cohort-topic-mesh-harness.js +15 -6
  45. package/dist/src/testing/cohort-topic-mesh-harness.js.map +1 -1
  46. package/package.json +3 -3
  47. package/src/cluster/service.ts +305 -293
  48. package/src/cohort-topic/host.ts +2932 -2901
  49. package/src/cohort-topic/stream-util.ts +147 -135
  50. package/src/libp2p-key-network.ts +1235 -1120
  51. package/src/libp2p-node-base.ts +1678 -1675
  52. package/src/logger.ts +27 -27
  53. package/src/matchmaking/query-transport.ts +492 -492
  54. package/src/peer-address-book.ts +266 -149
  55. package/src/reactivity/notify-transport.ts +144 -144
  56. package/src/reactivity/push-state-gossip.ts +291 -291
  57. package/src/reactivity/recover-transport.ts +412 -408
  58. package/src/repo/service.ts +323 -313
  59. package/src/routing/libp2p-known-peers.ts +31 -26
  60. 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 the two classes the diagnosability ticket named pass a peer id today
17
- * (`Libp2pKeyPeerNetwork`, `CoordinatorRepo`); 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');
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');