@optimystic/db-p2p 0.25.1 → 0.27.0
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/certified-claims.d.ts +17 -3
- package/dist/src/cluster/certified-claims.d.ts.map +1 -1
- package/dist/src/cluster/certified-claims.js +5 -3
- package/dist/src/cluster/certified-claims.js.map +1 -1
- package/dist/src/cluster/cluster-repo.d.ts +57 -92
- package/dist/src/cluster/cluster-repo.d.ts.map +1 -1
- package/dist/src/cluster/cluster-repo.js +149 -201
- package/dist/src/cluster/cluster-repo.js.map +1 -1
- package/dist/src/cluster/commit-proof.d.ts +16 -0
- package/dist/src/cluster/commit-proof.d.ts.map +1 -1
- package/dist/src/cluster/commit-proof.js +32 -1
- package/dist/src/cluster/commit-proof.js.map +1 -1
- package/dist/src/cluster/quorum-restore.d.ts +81 -28
- package/dist/src/cluster/quorum-restore.d.ts.map +1 -1
- package/dist/src/cluster/quorum-restore.js +148 -51
- package/dist/src/cluster/quorum-restore.js.map +1 -1
- package/dist/src/cluster/race-resolution.d.ts +89 -0
- package/dist/src/cluster/race-resolution.d.ts.map +1 -0
- package/dist/src/cluster/race-resolution.js +140 -0
- package/dist/src/cluster/race-resolution.js.map +1 -0
- package/dist/src/cluster/reconcile-block.d.ts +9 -4
- package/dist/src/cluster/reconcile-block.d.ts.map +1 -1
- package/dist/src/cluster/reconcile-block.js +28 -11
- package/dist/src/cluster/reconcile-block.js.map +1 -1
- package/dist/src/cluster/record-operations.d.ts +25 -0
- package/dist/src/cluster/record-operations.d.ts.map +1 -0
- package/dist/src/cluster/record-operations.js +56 -0
- package/dist/src/cluster/record-operations.js.map +1 -0
- package/dist/src/cohort-topic/host.d.ts +133 -51
- package/dist/src/cohort-topic/host.d.ts.map +1 -1
- package/dist/src/cohort-topic/host.js +290 -83
- package/dist/src/cohort-topic/host.js.map +1 -1
- package/dist/src/libp2p-node-base.d.ts +13 -4
- package/dist/src/libp2p-node-base.d.ts.map +1 -1
- package/dist/src/libp2p-node-base.js +5 -5
- package/dist/src/libp2p-node-base.js.map +1 -1
- package/dist/src/repo/cluster-coordinator.d.ts +9 -0
- package/dist/src/repo/cluster-coordinator.d.ts.map +1 -1
- package/dist/src/repo/cluster-coordinator.js +13 -2
- package/dist/src/repo/cluster-coordinator.js.map +1 -1
- package/dist/src/repo/coordinator-repo.d.ts +34 -2
- package/dist/src/repo/coordinator-repo.d.ts.map +1 -1
- package/dist/src/repo/coordinator-repo.js +57 -3
- package/dist/src/repo/coordinator-repo.js.map +1 -1
- package/dist/src/storage/block-latch.d.ts +5 -4
- package/dist/src/storage/block-latch.d.ts.map +1 -1
- package/dist/src/storage/block-latch.js +5 -4
- package/dist/src/storage/block-latch.js.map +1 -1
- package/dist/src/storage/block-storage.d.ts +1 -1
- package/dist/src/storage/block-storage.d.ts.map +1 -1
- package/dist/src/storage/block-storage.js +11 -3
- package/dist/src/storage/block-storage.js.map +1 -1
- package/dist/src/storage/cached-raw-storage.d.ts +17 -1
- package/dist/src/storage/cached-raw-storage.d.ts.map +1 -1
- package/dist/src/storage/cached-raw-storage.js +8 -1
- package/dist/src/storage/cached-raw-storage.js.map +1 -1
- package/dist/src/storage/cached-store-driver.d.ts +7 -0
- package/dist/src/storage/cached-store-driver.d.ts.map +1 -1
- package/dist/src/storage/cached-store-driver.js +20 -0
- package/dist/src/storage/cached-store-driver.js.map +1 -1
- package/dist/src/storage/i-block-storage.d.ts +45 -2
- package/dist/src/storage/i-block-storage.d.ts.map +1 -1
- package/dist/src/storage/i-block-storage.js +29 -0
- package/dist/src/storage/i-block-storage.js.map +1 -1
- package/dist/src/storage/i-raw-storage.d.ts +16 -0
- package/dist/src/storage/i-raw-storage.d.ts.map +1 -1
- package/dist/src/storage/kv-raw-storage.d.ts +5 -1
- package/dist/src/storage/kv-raw-storage.d.ts.map +1 -1
- package/dist/src/storage/kv-raw-storage.js +8 -1
- package/dist/src/storage/kv-raw-storage.js.map +1 -1
- package/dist/src/storage/raw-store-driver.d.ts +15 -0
- package/dist/src/storage/raw-store-driver.d.ts.map +1 -1
- package/dist/src/storage/shared-cache-pool.d.ts +5 -0
- package/dist/src/storage/shared-cache-pool.d.ts.map +1 -1
- package/dist/src/storage/shared-cache-pool.js +6 -1
- package/dist/src/storage/shared-cache-pool.js.map +1 -1
- package/dist/src/storage/storage-repo.d.ts.map +1 -1
- package/dist/src/storage/storage-repo.js +141 -99
- package/dist/src/storage/storage-repo.js.map +1 -1
- package/dist/src/storage/with-read-cache.d.ts +9 -5
- package/dist/src/storage/with-read-cache.d.ts.map +1 -1
- package/dist/src/storage/with-read-cache.js +16 -6
- package/dist/src/storage/with-read-cache.js.map +1 -1
- package/package.json +2 -2
- package/{README.md → readme.md} +2 -2
- package/src/cluster/certified-claims.ts +22 -9
- package/src/cluster/cluster-repo.ts +199 -212
- package/src/cluster/commit-proof.ts +38 -2
- package/src/cluster/quorum-restore.ts +183 -56
- package/src/cluster/race-resolution.ts +158 -0
- package/src/cluster/reconcile-block.ts +34 -11
- package/src/cluster/record-operations.ts +59 -0
- package/src/cohort-topic/host.ts +423 -118
- package/src/libp2p-node-base.ts +18 -9
- package/src/repo/cluster-coordinator.ts +1039 -1027
- package/src/repo/coordinator-repo.ts +1937 -1855
- package/src/storage/block-latch.ts +5 -4
- package/src/storage/block-storage.ts +11 -3
- package/src/storage/cached-raw-storage.ts +21 -1
- package/src/storage/cached-store-driver.ts +23 -0
- package/src/storage/i-block-storage.ts +47 -2
- package/src/storage/i-raw-storage.ts +17 -0
- package/src/storage/kv-raw-storage.ts +8 -1
- package/src/storage/raw-store-driver.ts +26 -0
- package/src/storage/shared-cache-pool.ts +6 -1
- package/src/storage/storage-repo.ts +143 -103
- package/src/storage/with-read-cache.ts +16 -6
|
@@ -102,8 +102,12 @@ class Lease implements ReadCacheLease {
|
|
|
102
102
|
* Returns the storage **unchanged**, with no `lease`, when caching would not pay:
|
|
103
103
|
* - `MemoryRawStorage` is already in memory; the cache would duplicate every map entry's
|
|
104
104
|
* bookkeeping with nothing to save (see `CachedStoreDriver`'s class doc).
|
|
105
|
-
* -
|
|
106
|
-
* and stays the host's to dispose.
|
|
105
|
+
* - A storage that reports {@link IRawStorage.readCached} (a host that attached a cache before
|
|
106
|
+
* handing it over) is not wrapped twice, and stays the host's to dispose. The capability, not
|
|
107
|
+
* a class check: BOTH documented constructions — `new CachedRawStorage(inner)` and
|
|
108
|
+
* `new KvRawStorage(new CachedStoreDriver(driver))` — report it, and only the first is a
|
|
109
|
+
* `CachedRawStorage`. Checking the class instead sent the driver-level shape down the
|
|
110
|
+
* construct path, where the pool's identity guard threw and the host's node failed to start.
|
|
107
111
|
*
|
|
108
112
|
* Why this is needed at all: `BlockStorage` re-reads block metadata on essentially every
|
|
109
113
|
* operation and `StorageRepo` builds a fresh `BlockStorage` per block per call, so nothing above
|
|
@@ -122,9 +126,9 @@ class Lease implements ReadCacheLease {
|
|
|
122
126
|
* unwrapped instance handed to two consumers). Identity is one-directional — equal proves
|
|
123
127
|
* sameness, unequal proves nothing — so backends whose identity under-approximates (path
|
|
124
128
|
* aliases, two handles over one database; each backend's `NOTE:` lists its gaps) can still end
|
|
125
|
-
* up with two caches; and a host that builds its own
|
|
126
|
-
* registry, so a second consumer wrapping a fresh instance over that store still gets
|
|
127
|
-
* cache. What remains of Invariant 5 (`packages/db-p2p/docs/storage.md`) is the cross-process
|
|
129
|
+
* up with two caches; and a host that builds its own cache — in either construction — never
|
|
130
|
+
* enters the registry, so a second consumer wrapping a fresh instance over that store still gets
|
|
131
|
+
* a second cache. What remains of Invariant 5 (`packages/db-p2p/docs/storage.md`) is the cross-process
|
|
128
132
|
* case: the filesystem driver takes no lock, and a second process's writes bypass this cache.
|
|
129
133
|
*
|
|
130
134
|
* On a dedupe hit the FIRST caller's `label` and `pool` stick: `pool.stats()` shows whoever
|
|
@@ -148,7 +152,13 @@ class Lease implements ReadCacheLease {
|
|
|
148
152
|
* dedupe hit.
|
|
149
153
|
*/
|
|
150
154
|
export function withReadCache(storage: IRawStorage, label?: string, pool?: SharedCachePool): ResolvedReadCache {
|
|
151
|
-
|
|
155
|
+
// `readCached` is a plain property read, which keeps this whole function synchronous — see
|
|
156
|
+
// the "no `await` between lookup and insert" note above; never make it an accessor that
|
|
157
|
+
// could become async. `MemoryRawStorage` never carries the marker (its driver is uncached);
|
|
158
|
+
// it is excluded for a different reason and keeps its own class check. Note a plain
|
|
159
|
+
// `KvRawStorage` over a bare `MemoryStoreDriver` is NOT a `MemoryRawStorage` and is still
|
|
160
|
+
// wrapped — deliberate, and pinned by a test.
|
|
161
|
+
if (storage instanceof MemoryRawStorage || storage.readCached) {
|
|
152
162
|
return { storage, lease: undefined };
|
|
153
163
|
}
|
|
154
164
|
|