@optimystic/db-p2p 1.0.0-beta.2 → 1.0.0-beta.3
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/cluster-repo.d.ts +46 -11
- package/dist/src/cluster/cluster-repo.d.ts.map +1 -1
- package/dist/src/cluster/cluster-repo.js +177 -101
- package/dist/src/cluster/cluster-repo.js.map +1 -1
- package/dist/src/libp2p-key-network.d.ts.map +1 -1
- package/dist/src/libp2p-key-network.js +7 -0
- package/dist/src/libp2p-key-network.js.map +1 -1
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/logger.js +13 -6
- package/dist/src/logger.js.map +1 -1
- package/dist/src/repo/cluster-coordinator.d.ts +42 -0
- package/dist/src/repo/cluster-coordinator.d.ts.map +1 -1
- package/dist/src/repo/cluster-coordinator.js +50 -9
- package/dist/src/repo/cluster-coordinator.js.map +1 -1
- package/dist/src/repo/coordinator-repo.d.ts +74 -7
- package/dist/src/repo/coordinator-repo.d.ts.map +1 -1
- package/dist/src/repo/coordinator-repo.js +290 -55
- package/dist/src/repo/coordinator-repo.js.map +1 -1
- package/dist/src/storage/storage-repo.d.ts +15 -0
- package/dist/src/storage/storage-repo.d.ts.map +1 -1
- package/dist/src/storage/storage-repo.js +28 -0
- package/dist/src/storage/storage-repo.js.map +1 -1
- package/dist/src/testing/mesh-harness.d.ts +15 -0
- package/dist/src/testing/mesh-harness.d.ts.map +1 -1
- package/dist/src/testing/mesh-harness.js +21 -4
- package/dist/src/testing/mesh-harness.js.map +1 -1
- package/package.json +2 -2
- package/src/cluster/cluster-repo.ts +2749 -2671
- package/src/libp2p-key-network.ts +7 -0
- package/src/logger.ts +14 -6
- package/src/repo/cluster-coordinator.ts +1170 -1113
- package/src/repo/coordinator-repo.ts +2940 -2687
- package/src/storage/storage-repo.ts +30 -0
- package/src/testing/mesh-harness.ts +37 -4
|
@@ -966,6 +966,13 @@ export class Libp2pKeyPeerNetwork implements IKeyNetwork, IPeerNetwork {
|
|
|
966
966
|
return byPeer
|
|
967
967
|
}
|
|
968
968
|
|
|
969
|
+
// NOTE: accepted tradeoff — a node with no peers recomputes the self-only cohort on every call
|
|
970
|
+
// (~2 per distinct block read; 144 calls in a 67-object cold apply). Measured 0.009 ms/call on
|
|
971
|
+
// Node with a wildcard TCP listener (test/bench-findcluster.mjs, N=2000, 2026-09-11), so a memo
|
|
972
|
+
// would save ~1.3 ms per apply while adding an invalidation hazard: a node that gains a peer, or
|
|
973
|
+
// finishes identifying one, must stop answering self-only immediately, and read-repair recovery
|
|
974
|
+
// relies on that widening. Revisit if an on-device (React Native) profile shows findCluster as
|
|
975
|
+
// material; then memoize ONLY the solo answer, invalidated on connection:open and peer:identify.
|
|
969
976
|
async findCluster(key: Uint8Array): Promise<ClusterPeers> {
|
|
970
977
|
const t0 = Date.now();
|
|
971
978
|
const fret = this.getFret()
|
package/src/logger.ts
CHANGED
|
@@ -2,12 +2,16 @@ import { base32 } from 'multiformats/bases/base32'
|
|
|
2
2
|
import { base58btc } from 'multiformats/bases/base58'
|
|
3
3
|
import { base64 } from 'multiformats/bases/base64'
|
|
4
4
|
import debug from 'debug'
|
|
5
|
+
import { registerDebugModule } from '@optimystic/db-core'
|
|
5
6
|
import type { PeerId } from '@libp2p/interface'
|
|
6
7
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
7
8
|
import type { CID } from 'multiformats/cid'
|
|
8
9
|
|
|
9
10
|
const BASE_NAMESPACE = 'optimystic:db-p2p'
|
|
10
11
|
|
|
12
|
+
// So `enableOptimysticLogging` reaches this package's copy of `debug`, which may be no one else's.
|
|
13
|
+
registerDebugModule('db-p2p', debug)
|
|
14
|
+
|
|
11
15
|
/*
|
|
12
16
|
* Format specifiers, ported from `@libp2p/logger`'s `src/index.ts` (MIT, same license as this
|
|
13
17
|
* repo). Call sites in this package log lines like `'error handling X from %p - %e'`; those used
|
|
@@ -18,12 +22,16 @@ const BASE_NAMESPACE = 'optimystic:db-p2p'
|
|
|
18
22
|
* loggers use `weald` (via @libp2p/logger) and carry their own copy — the two registries are
|
|
19
23
|
* independent, and enabling one from test code does not enable the other.
|
|
20
24
|
*
|
|
21
|
-
* NOTE: `debug.formatters`
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
25
|
+
* NOTE: `debug.formatters` belongs to the one copy of `debug` this file imports. Whether the other
|
|
26
|
+
* six packages' `createLogger` factories share that copy depends on whether the install dedupes
|
|
27
|
+
* `debug` — and this repo's own install does not (`nmHoistingLimits: workspaces` in `.yarnrc.yml`
|
|
28
|
+
* gives every package its own copy). So treat these specifiers as db-p2p-only; nothing outside
|
|
29
|
+
* db-p2p uses them today. Do not register them on other copies to paper over that — if another
|
|
30
|
+
* package ever needs one, move the formatters into a module both import deliberately.
|
|
31
|
+
* Where an install DOES dedupe, they reach every package sharing the copy: harmless today (no other
|
|
32
|
+
* package registers any specifier, and none of these letters is a `util.format` specifier except
|
|
33
|
+
* `%c`, whose Node meaning is a no-op that swallows its argument), but if a second package ever
|
|
34
|
+
* registers one of these letters on a shared copy, last import wins silently.
|
|
27
35
|
*
|
|
28
36
|
* NOTE: only `%e` is guaranteed not to throw — its call sites take a `catch`-bound `unknown`. The
|
|
29
37
|
* other six call `.toString()` / an encoder on whatever they are handed, so a caller that passes
|