@optimystic/db-core 1.20.1 → 1.22.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/btree/btree.d.ts +36 -4
- package/dist/src/btree/btree.d.ts.map +1 -1
- package/dist/src/btree/btree.js +86 -18
- package/dist/src/btree/btree.js.map +1 -1
- package/dist/src/cohort-topic/gossip/bus.d.ts +15 -14
- package/dist/src/cohort-topic/gossip/bus.d.ts.map +1 -1
- package/dist/src/cohort-topic/gossip/bus.js +15 -16
- package/dist/src/cohort-topic/gossip/bus.js.map +1 -1
- package/dist/src/cohort-topic/ports.d.ts +30 -4
- package/dist/src/cohort-topic/ports.d.ts.map +1 -1
- package/dist/src/cohort-topic/ports.js +14 -0
- package/dist/src/cohort-topic/ports.js.map +1 -1
- package/dist/src/cohort-topic/registration/renewal.d.ts +27 -1
- package/dist/src/cohort-topic/registration/renewal.d.ts.map +1 -1
- package/dist/src/cohort-topic/registration/renewal.js +15 -4
- package/dist/src/cohort-topic/registration/renewal.js.map +1 -1
- package/dist/src/cohort-topic/service.d.ts +21 -4
- package/dist/src/cohort-topic/service.d.ts.map +1 -1
- package/dist/src/cohort-topic/service.js +208 -18
- package/dist/src/cohort-topic/service.js.map +1 -1
- package/dist/src/cohort-topic/willingness.d.ts +1 -1
- package/dist/src/cohort-topic/willingness.js +1 -1
- package/dist/src/cohort-topic/wire/codec.d.ts +3 -1
- package/dist/src/cohort-topic/wire/codec.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/codec.js +7 -1
- package/dist/src/cohort-topic/wire/codec.js.map +1 -1
- package/dist/src/cohort-topic/wire/index.d.ts +1 -1
- package/dist/src/cohort-topic/wire/index.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/index.js +1 -1
- package/dist/src/cohort-topic/wire/index.js.map +1 -1
- package/dist/src/cohort-topic/wire/types.d.ts +17 -1
- package/dist/src/cohort-topic/wire/types.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/validate.d.ts +15 -1
- package/dist/src/cohort-topic/wire/validate.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/validate.js +39 -0
- package/dist/src/cohort-topic/wire/validate.js.map +1 -1
- package/dist/src/collection/collection.d.ts +43 -5
- package/dist/src/collection/collection.d.ts.map +1 -1
- package/dist/src/collection/collection.js +60 -13
- package/dist/src/collection/collection.js.map +1 -1
- package/dist/src/collection/struct.d.ts +6 -0
- package/dist/src/collection/struct.d.ts.map +1 -1
- package/dist/src/collection/struct.js.map +1 -1
- package/dist/src/collections/tree/tree.d.ts +3 -1
- package/dist/src/collections/tree/tree.d.ts.map +1 -1
- package/dist/src/collections/tree/tree.js +11 -5
- package/dist/src/collections/tree/tree.js.map +1 -1
- package/dist/src/network/struct.d.ts +15 -0
- package/dist/src/network/struct.d.ts.map +1 -1
- package/dist/src/network/struct.js.map +1 -1
- package/dist/src/testing/test-transactor.js +6 -2
- package/dist/src/testing/test-transactor.js.map +1 -1
- package/dist/src/transaction/coordinator.d.ts +6 -0
- package/dist/src/transaction/coordinator.d.ts.map +1 -1
- package/dist/src/transaction/coordinator.js +6 -0
- package/dist/src/transaction/coordinator.js.map +1 -1
- package/dist/src/transactor/network-transactor.d.ts.map +1 -1
- package/dist/src/transactor/network-transactor.js +1 -0
- package/dist/src/transactor/network-transactor.js.map +1 -1
- package/package.json +1 -1
- package/src/btree/btree.ts +92 -18
- package/src/cohort-topic/gossip/bus.ts +25 -26
- package/src/cohort-topic/ports.ts +31 -4
- package/src/cohort-topic/registration/renewal.ts +40 -5
- package/src/cohort-topic/service.ts +251 -21
- package/src/cohort-topic/willingness.ts +1 -1
- package/src/cohort-topic/wire/codec.ts +12 -0
- package/src/cohort-topic/wire/index.ts +3 -0
- package/src/cohort-topic/wire/types.ts +20 -0
- package/src/cohort-topic/wire/validate.ts +45 -0
- package/src/collection/collection.ts +3098 -3039
- package/src/collection/struct.ts +463 -456
- package/src/collections/tree/tree.ts +15 -7
- package/src/network/struct.ts +770 -755
- package/src/testing/test-transactor.ts +5 -2
- package/src/transaction/coordinator.ts +6 -0
- package/src/transactor/network-transactor.ts +1897 -1896
|
@@ -173,13 +173,14 @@ export interface TreeReadView<TKey, TEntry> {
|
|
|
173
173
|
get(key: TKey): Promise<TEntry | undefined>;
|
|
174
174
|
at(path: Path<TKey, TEntry>): TEntry | undefined;
|
|
175
175
|
range(range: KeyRange<TKey>): AsyncIterableIterator<Path<TKey, TEntry>>;
|
|
176
|
+
entriesIn(range: KeyRange<TKey>): Promise<TEntry[]>;
|
|
176
177
|
ascending(path: Path<TKey, TEntry>): AsyncIterableIterator<Path<TKey, TEntry>>;
|
|
177
178
|
isValid(path: Path<TKey, TEntry>): boolean;
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
/** Carries the read {@link BTree} from wherever it gets built (the `createHeaderBlock`
|
|
181
|
-
* callback on the create path, {@link Tree.attach} on the open path) to the
|
|
182
|
-
*
|
|
182
|
+
* callback on the create path, {@link Tree.attach} on the open path) to the collection's
|
|
183
|
+
* `onViewChanged` callback, which needs the live instance to invalidate outstanding paths. */
|
|
183
184
|
interface BTreeHolder<TKey, TEntry> {
|
|
184
185
|
btree?: BTree<TKey, TEntry>;
|
|
185
186
|
}
|
|
@@ -318,13 +319,16 @@ export class Tree<TKey, TEntry> implements TreeReadView<TKey, TEntry> {
|
|
|
318
319
|
await actionTree.deleteAt(path);
|
|
319
320
|
}
|
|
320
321
|
}
|
|
321
|
-
// Mutations landed in `trx`, not the read btree, so its version counter never moved.
|
|
322
|
-
// Bump it to invalidate any Path a caller still holds — preserving the path-invalidation
|
|
323
|
-
// the previous in-place handler gave for free.
|
|
324
|
-
held.btree?.invalidatePaths();
|
|
325
322
|
return tally.result();
|
|
326
323
|
}
|
|
327
324
|
},
|
|
325
|
+
// Mutations land in `trx` and in the collection's cache, never through the read btree, so
|
|
326
|
+
// its version counter would never move on its own. The collection says when what its reads
|
|
327
|
+
// see changes — a staged action landing, a replay, a restore, a refresh, a commit folded in
|
|
328
|
+
// — and the bump invalidates every Path handed out before, and tells a point read or a
|
|
329
|
+
// range scan's setup part-way through a descent to read again (docs/btree.md §Reads under
|
|
330
|
+
// a concurrent change).
|
|
331
|
+
onViewChanged: () => held.btree?.invalidatePaths(),
|
|
328
332
|
createHeaderBlock: (hid: BlockId, store: BlockStore<IBlock>) => { // Only called if the collection does not exist
|
|
329
333
|
// Tricky bootstrapping here:
|
|
330
334
|
// We need the root id to initialize the collection header, so we create the btree here.
|
|
@@ -344,7 +348,7 @@ export class Tree<TKey, TEntry> implements TreeReadView<TKey, TEntry> {
|
|
|
344
348
|
/** Bind an opened collection to its read btree. On the create path `createHeaderBlock` already
|
|
345
349
|
* built one (it needed the root id for the header); on the open path it never ran, so build it
|
|
346
350
|
* over the collection's existing tracker. Either way the result is written back into `held` so
|
|
347
|
-
* the
|
|
351
|
+
* the collection's path-invalidation (`onViewChanged`) targets the very btree reads go through. */
|
|
348
352
|
private static attach<TKey, TEntry>(
|
|
349
353
|
collection: Collection<TreeReplaceAction<TKey, TEntry>>,
|
|
350
354
|
held: BTreeHolder<TKey, TEntry>,
|
|
@@ -526,6 +530,10 @@ export class Tree<TKey, TEntry> implements TreeReadView<TKey, TEntry> {
|
|
|
526
530
|
return this.btree.range(range);
|
|
527
531
|
}
|
|
528
532
|
|
|
533
|
+
async entriesIn(range: KeyRange<TKey>): Promise<TEntry[]> {
|
|
534
|
+
return await this.btree.entriesIn(range);
|
|
535
|
+
}
|
|
536
|
+
|
|
529
537
|
ascending(path: Path<TKey, TEntry>): AsyncIterableIterator<Path<TKey, TEntry>> {
|
|
530
538
|
return this.btree.ascending(path);
|
|
531
539
|
}
|