@optimystic/db-core 1.26.0 → 1.28.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.
Files changed (77) hide show
  1. package/dist/src/chain/chain.d.ts +4 -0
  2. package/dist/src/chain/chain.d.ts.map +1 -1
  3. package/dist/src/chain/chain.js +15 -3
  4. package/dist/src/chain/chain.js.map +1 -1
  5. package/dist/src/cluster/membership.d.ts +9 -2
  6. package/dist/src/cluster/membership.d.ts.map +1 -1
  7. package/dist/src/cluster/membership.js +51 -11
  8. package/dist/src/cluster/membership.js.map +1 -1
  9. package/dist/src/cluster/structs.d.ts +21 -0
  10. package/dist/src/cluster/structs.d.ts.map +1 -1
  11. package/dist/src/cohort-topic/willingness.d.ts +12 -11
  12. package/dist/src/cohort-topic/willingness.d.ts.map +1 -1
  13. package/dist/src/cohort-topic/willingness.js +21 -11
  14. package/dist/src/cohort-topic/willingness.js.map +1 -1
  15. package/dist/src/collection/collection.d.ts +46 -2
  16. package/dist/src/collection/collection.d.ts.map +1 -1
  17. package/dist/src/collection/collection.js +65 -15
  18. package/dist/src/collection/collection.js.map +1 -1
  19. package/dist/src/collection/segments.d.ts +16 -3
  20. package/dist/src/collection/segments.d.ts.map +1 -1
  21. package/dist/src/collection/segments.js +24 -7
  22. package/dist/src/collection/segments.js.map +1 -1
  23. package/dist/src/collection/write-attempts.d.ts +5 -3
  24. package/dist/src/collection/write-attempts.d.ts.map +1 -1
  25. package/dist/src/collection/write-attempts.js +7 -5
  26. package/dist/src/collection/write-attempts.js.map +1 -1
  27. package/dist/src/collections/tree/tree.d.ts +5 -4
  28. package/dist/src/collections/tree/tree.d.ts.map +1 -1
  29. package/dist/src/collections/tree/tree.js +1 -1
  30. package/dist/src/collections/tree/tree.js.map +1 -1
  31. package/dist/src/network/block-size.d.ts +30 -5
  32. package/dist/src/network/block-size.d.ts.map +1 -1
  33. package/dist/src/network/block-size.js +34 -6
  34. package/dist/src/network/block-size.js.map +1 -1
  35. package/dist/src/network/i-key-network.d.ts +28 -0
  36. package/dist/src/network/i-key-network.d.ts.map +1 -1
  37. package/dist/src/network/i-peer-network.d.ts +5 -0
  38. package/dist/src/network/i-peer-network.d.ts.map +1 -1
  39. package/dist/src/network/i-repo.d.ts +4 -0
  40. package/dist/src/network/i-repo.d.ts.map +1 -1
  41. package/dist/src/network/promise-shortfall-error.d.ts +5 -1
  42. package/dist/src/network/promise-shortfall-error.d.ts.map +1 -1
  43. package/dist/src/network/promise-shortfall-error.js +5 -1
  44. package/dist/src/network/promise-shortfall-error.js.map +1 -1
  45. package/dist/src/network/struct.d.ts +5 -1
  46. package/dist/src/network/struct.d.ts.map +1 -1
  47. package/dist/src/network/struct.js.map +1 -1
  48. package/dist/src/network/transaction-size.d.ts +37 -8
  49. package/dist/src/network/transaction-size.d.ts.map +1 -1
  50. package/dist/src/network/transaction-size.js +36 -7
  51. package/dist/src/network/transaction-size.js.map +1 -1
  52. package/dist/src/transaction/coordinator.d.ts +5 -3
  53. package/dist/src/transaction/coordinator.d.ts.map +1 -1
  54. package/dist/src/transaction/coordinator.js +9 -7
  55. package/dist/src/transaction/coordinator.js.map +1 -1
  56. package/dist/src/transform/helpers.d.ts +12 -2
  57. package/dist/src/transform/helpers.d.ts.map +1 -1
  58. package/dist/src/transform/helpers.js +18 -2
  59. package/dist/src/transform/helpers.js.map +1 -1
  60. package/package.json +1 -1
  61. package/src/chain/chain.ts +15 -3
  62. package/src/cluster/membership.ts +129 -87
  63. package/src/cluster/structs.ts +21 -0
  64. package/src/cohort-topic/willingness.ts +39 -22
  65. package/src/collection/collection.ts +78 -14
  66. package/src/collection/segments.ts +30 -7
  67. package/src/collection/write-attempts.ts +7 -5
  68. package/src/collections/tree/tree.ts +5 -4
  69. package/src/network/block-size.ts +40 -6
  70. package/src/network/i-key-network.ts +30 -0
  71. package/src/network/i-peer-network.ts +6 -0
  72. package/src/network/i-repo.ts +4 -0
  73. package/src/network/promise-shortfall-error.ts +5 -1
  74. package/src/network/struct.ts +5 -1
  75. package/src/network/transaction-size.ts +35 -7
  76. package/src/transaction/coordinator.ts +9 -6
  77. package/src/transform/helpers.ts +19 -2
@@ -162,8 +162,9 @@ export function concatTransforms(...transforms: Transforms[]): Transforms {
162
162
  * when `updates` ride along) to affect the original Transforms.
163
163
  * @see docs/internals.md "Shallow Copy of Transforms" pitfall
164
164
  *
165
- * NOTE: clones unconditionally, even for read-only callers (e.g. StorageRepo.pend's classify pass);
166
- * if large inserts ever show up in a pend/commit profile, add a non-cloning variant for those callers.
165
+ * NOTE: clones unconditionally, even for read-only callers (the reservation reads in
166
+ * `ClusterMember.reservationRequestOf` and `CoordinatorRepo.corroborateHeldBlocks`, both in cohorts of
167
+ * four and up); if they ever show up in a pend profile, give them {@link sharedTransformForBlockId}.
167
168
  */
168
169
  export function transformForBlockId(transform: Transforms, blockId: BlockId): Transform {
169
170
  return {
@@ -175,6 +176,22 @@ export function transformForBlockId(transform: Transforms, blockId: BlockId): Tr
175
176
  };
176
177
  }
177
178
 
179
+ /**
180
+ * The transform for one block, SHARING `transform`'s inserted block and update list rather than
181
+ * copying them: for a caller that only reads the result, or serializes it at once, and keeps nothing
182
+ * of it. `StorageRepo.pend` reads it to classify a block and hands it to storage, which encodes it to
183
+ * JSON before returning. Anything that applies, changes or holds on to the result takes
184
+ * {@link transformForBlockId}, whose copy is what makes that safe.
185
+ * @see docs/internals.md "Functions That Share"
186
+ */
187
+ export function sharedTransformForBlockId(transform: Transforms, blockId: BlockId): Transform {
188
+ return {
189
+ ...(transform.inserts && blockId in transform.inserts ? { insert: transform.inserts[blockId]! } : {}),
190
+ ...(transform.updates && blockId in transform.updates ? { updates: transform.updates[blockId]! } : {}),
191
+ ...(transform.deletes?.includes(blockId) ? { delete: true } : {})
192
+ };
193
+ }
194
+
178
195
  export function transformsFromTransform(transform: Transform, blockId: BlockId): Transforms {
179
196
  return {
180
197
  inserts: transform.insert ? { [blockId]: transform.insert } : {},