@optimystic/db-core 1.6.0 → 1.8.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/structs.d.ts +6 -2
- package/dist/src/cluster/structs.d.ts.map +1 -1
- package/dist/src/collection/collection.d.ts +39 -3
- package/dist/src/collection/collection.d.ts.map +1 -1
- package/dist/src/collection/collection.js +68 -12
- package/dist/src/collection/collection.js.map +1 -1
- package/dist/src/network/i-key-network.d.ts +14 -9
- package/dist/src/network/i-key-network.d.ts.map +1 -1
- package/dist/src/network/i-repo.d.ts +8 -0
- package/dist/src/network/i-repo.d.ts.map +1 -1
- package/dist/src/network/struct.d.ts +37 -10
- package/dist/src/network/struct.d.ts.map +1 -1
- package/dist/src/network/struct.js.map +1 -1
- package/dist/src/transactor/network-transactor.d.ts.map +1 -1
- package/dist/src/transactor/network-transactor.js +18 -2
- package/dist/src/transactor/network-transactor.js.map +1 -1
- package/package.json +1 -1
- package/src/cluster/structs.ts +6 -2
- package/src/collection/collection.ts +72 -13
- package/src/network/i-key-network.ts +14 -9
- package/src/network/i-repo.ts +8 -0
- package/src/network/struct.ts +37 -10
- package/src/transactor/network-transactor.ts +20 -2
|
@@ -144,12 +144,17 @@ export class NetworkTransactor implements ITransactor, IBlockChangeNotifier {
|
|
|
144
144
|
);
|
|
145
145
|
|
|
146
146
|
const expiration = Date.now() + this.timeoutMs;
|
|
147
|
+
// Both rounds forward the caller's floors for the batch's blocks. A repo that predates the
|
|
148
|
+
// field ignores it and answers as before; the `belowFloor` check below is what holds the floor
|
|
149
|
+
// either way, so forwarding adds a chance of a first answer that meets it, never a guarantee.
|
|
150
|
+
const askRepo = (batch: CoordinatorBatch<BlockId[], GetBlockResults>) =>
|
|
151
|
+
this.getRepo(batch.peerId).get(downstreamGets(batch.payload, blockGets), { expiration, dialTimeoutMs: this.dialTimeoutMs });
|
|
147
152
|
|
|
148
153
|
let error: Error | undefined;
|
|
149
154
|
try {
|
|
150
155
|
await processBatches(
|
|
151
156
|
batches,
|
|
152
|
-
|
|
157
|
+
askRepo,
|
|
153
158
|
batch => batch.payload,
|
|
154
159
|
(gets, blockId, mergeWithGets) => [...(mergeWithGets ?? []), ...gets.filter(bid => bid === blockId)],
|
|
155
160
|
expiration,
|
|
@@ -254,7 +259,7 @@ export class NetworkTransactor implements ITransactor, IBlockChangeNotifier {
|
|
|
254
259
|
b.subsumedBy = [...(b.subsumedBy ?? []), ...retries];
|
|
255
260
|
await processBatches(
|
|
256
261
|
retries,
|
|
257
|
-
|
|
262
|
+
askRepo,
|
|
258
263
|
batch => batch.payload,
|
|
259
264
|
(gets, blockId, mergeWithGets) => [...(mergeWithGets ?? []), ...gets.filter(id => id === blockId)],
|
|
260
265
|
expiration,
|
|
@@ -1489,6 +1494,19 @@ function pendRequestForBatch(action: PendRequest, payload: Transforms): PendRequ
|
|
|
1489
1494
|
return { ...rest, transforms: payload, ...baseRevsFor(baseRevs, blockIdsForTransforms(payload)) };
|
|
1490
1495
|
}
|
|
1491
1496
|
|
|
1497
|
+
/** The read one coordinator batch sends downstream: the batch's ids, the caller's context, and the
|
|
1498
|
+
* caller's floors for those ids alone (see {@link BlockGets.floors}). The `floors` key is left off
|
|
1499
|
+
* entirely when no block in the batch has one, so an unfloored read goes out exactly as it did before
|
|
1500
|
+
* floors travelled. Same send-time rule as {@link digestsFor}, for the same reason. */
|
|
1501
|
+
function downstreamGets(batchBlockIds: BlockId[], blockGets: BlockGets): BlockGets {
|
|
1502
|
+
const floors = blockGets.floors === undefined ? {} : subsetOf(blockGets.floors, batchBlockIds);
|
|
1503
|
+
return {
|
|
1504
|
+
blockIds: batchBlockIds,
|
|
1505
|
+
context: blockGets.context,
|
|
1506
|
+
...(isRecordEmpty(floors) ? {} : { floors }),
|
|
1507
|
+
};
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1492
1510
|
/**
|
|
1493
1511
|
* The owning collection id for an action ref, read from any fetched block's header. A
|
|
1494
1512
|
* committed-then-invalidated action still has a materialized (compensating) block whose header carries
|