cojson-storage-indexeddb 0.8.12 → 0.8.16
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/CHANGELOG.md +157 -150
- package/dist/index.js +15 -38
- package/dist/index.js.map +1 -1
- package/dist/syncPromises.js.map +1 -1
- package/dist/tests/index.test.js +1 -1
- package/dist/tests/index.test.js.map +1 -1
- package/package.json +5 -9
- package/src/index.ts +663 -721
- package/src/syncPromises.ts +181 -186
- package/src/tests/index.test.ts +39 -39
- package/tsconfig.json +2 -2
- package/.eslintrc.cjs +0 -24
- package/.prettierrc.js +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,417 +1,424 @@
|
|
|
1
1
|
# cojson-storage-indexeddb
|
|
2
2
|
|
|
3
|
+
## 0.8.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [b934fab]
|
|
8
|
+
- cojson@0.8.16
|
|
9
|
+
|
|
3
10
|
## 0.8.12
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
6
13
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
|
|
14
|
+
- 6ed75eb: Introduce "storage" peer role
|
|
15
|
+
- Updated dependencies [6ed75eb]
|
|
16
|
+
- cojson@0.8.12
|
|
10
17
|
|
|
11
18
|
## 0.8.11
|
|
12
19
|
|
|
13
20
|
### Patch Changes
|
|
14
21
|
|
|
15
|
-
-
|
|
16
|
-
|
|
22
|
+
- Updated dependencies [1ed4ab5]
|
|
23
|
+
- cojson@0.8.11
|
|
17
24
|
|
|
18
25
|
## 0.8.5
|
|
19
26
|
|
|
20
27
|
### Patch Changes
|
|
21
28
|
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
|
|
29
|
+
- Updated dependencies [c3f4e6b]
|
|
30
|
+
- Updated dependencies [d9152ed]
|
|
31
|
+
- cojson@0.8.5
|
|
25
32
|
|
|
26
33
|
## 0.8.3
|
|
27
34
|
|
|
28
35
|
### Patch Changes
|
|
29
36
|
|
|
30
|
-
-
|
|
31
|
-
|
|
37
|
+
- Updated dependencies
|
|
38
|
+
- cojson@0.8.3
|
|
32
39
|
|
|
33
40
|
## 0.8.0
|
|
34
41
|
|
|
35
42
|
### Patch Changes
|
|
36
43
|
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
|
|
44
|
+
- Updated dependencies [6a147c2]
|
|
45
|
+
- Updated dependencies [ad40b88]
|
|
46
|
+
- cojson@0.8.0
|
|
40
47
|
|
|
41
48
|
## 0.7.35
|
|
42
49
|
|
|
43
50
|
### Patch Changes
|
|
44
51
|
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
|
|
52
|
+
- f350e90: Added a priority system for the sync messages
|
|
53
|
+
- Updated dependencies [35bbcd9]
|
|
54
|
+
- Updated dependencies [f350e90]
|
|
55
|
+
- cojson@0.7.35
|
|
49
56
|
|
|
50
57
|
## 0.7.34
|
|
51
58
|
|
|
52
59
|
### Patch Changes
|
|
53
60
|
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
|
|
61
|
+
- Updated dependencies [5d91f9f]
|
|
62
|
+
- Updated dependencies [5094e6d]
|
|
63
|
+
- Updated dependencies [b09589b]
|
|
64
|
+
- Updated dependencies [2c3a40c]
|
|
65
|
+
- Updated dependencies [4e16575]
|
|
66
|
+
- Updated dependencies [ea882ab]
|
|
67
|
+
- cojson@0.7.34
|
|
61
68
|
|
|
62
69
|
## 0.7.34-neverthrow.8
|
|
63
70
|
|
|
64
71
|
### Patch Changes
|
|
65
72
|
|
|
66
|
-
-
|
|
67
|
-
|
|
73
|
+
- Updated dependencies
|
|
74
|
+
- cojson@0.7.34-neverthrow.8
|
|
68
75
|
|
|
69
76
|
## 0.7.34-neverthrow.7
|
|
70
77
|
|
|
71
78
|
### Patch Changes
|
|
72
79
|
|
|
73
|
-
-
|
|
74
|
-
|
|
80
|
+
- Updated dependencies
|
|
81
|
+
- cojson@0.7.34-neverthrow.7
|
|
75
82
|
|
|
76
83
|
## 0.7.34-neverthrow.4
|
|
77
84
|
|
|
78
85
|
### Patch Changes
|
|
79
86
|
|
|
80
|
-
-
|
|
81
|
-
|
|
87
|
+
- Updated dependencies
|
|
88
|
+
- cojson@0.7.34-neverthrow.4
|
|
82
89
|
|
|
83
90
|
## 0.7.34-neverthrow.3
|
|
84
91
|
|
|
85
92
|
### Patch Changes
|
|
86
93
|
|
|
87
|
-
-
|
|
88
|
-
|
|
94
|
+
- Updated dependencies
|
|
95
|
+
- cojson@0.7.34-neverthrow.3
|
|
89
96
|
|
|
90
97
|
## 0.7.34-neverthrow.1
|
|
91
98
|
|
|
92
99
|
### Patch Changes
|
|
93
100
|
|
|
94
|
-
-
|
|
95
|
-
|
|
101
|
+
- Updated dependencies
|
|
102
|
+
- cojson@0.7.34-neverthrow.1
|
|
96
103
|
|
|
97
104
|
## 0.7.34-neverthrow.0
|
|
98
105
|
|
|
99
106
|
### Patch Changes
|
|
100
107
|
|
|
101
|
-
-
|
|
102
|
-
|
|
108
|
+
- Updated dependencies
|
|
109
|
+
- cojson@0.7.34-neverthrow.0
|
|
103
110
|
|
|
104
111
|
## 0.7.33
|
|
105
112
|
|
|
106
113
|
### Patch Changes
|
|
107
114
|
|
|
108
|
-
-
|
|
109
|
-
-
|
|
110
|
-
-
|
|
111
|
-
-
|
|
112
|
-
-
|
|
113
|
-
|
|
115
|
+
- 3bf5127: Allow crashing whole node on peer errors
|
|
116
|
+
- Updated dependencies [b297c93]
|
|
117
|
+
- Updated dependencies [3bf5127]
|
|
118
|
+
- Updated dependencies [a8b74ff]
|
|
119
|
+
- Updated dependencies [db53161]
|
|
120
|
+
- cojson@0.7.33
|
|
114
121
|
|
|
115
122
|
## 0.7.33-hotfixes.5
|
|
116
123
|
|
|
117
124
|
### Patch Changes
|
|
118
125
|
|
|
119
|
-
-
|
|
120
|
-
|
|
126
|
+
- Updated dependencies
|
|
127
|
+
- cojson@0.7.33-hotfixes.5
|
|
121
128
|
|
|
122
129
|
## 0.7.33-hotfixes.4
|
|
123
130
|
|
|
124
131
|
### Patch Changes
|
|
125
132
|
|
|
126
|
-
-
|
|
127
|
-
|
|
133
|
+
- Updated dependencies
|
|
134
|
+
- cojson@0.7.33-hotfixes.4
|
|
128
135
|
|
|
129
136
|
## 0.7.33-hotfixes.3
|
|
130
137
|
|
|
131
138
|
### Patch Changes
|
|
132
139
|
|
|
133
|
-
-
|
|
134
|
-
-
|
|
135
|
-
|
|
140
|
+
- Allow crashing whole node on peer errors
|
|
141
|
+
- Updated dependencies
|
|
142
|
+
- cojson@0.7.33-hotfixes.3
|
|
136
143
|
|
|
137
144
|
## 0.7.33-hotfixes.0
|
|
138
145
|
|
|
139
146
|
### Patch Changes
|
|
140
147
|
|
|
141
|
-
-
|
|
142
|
-
|
|
148
|
+
- Updated dependencies
|
|
149
|
+
- cojson@0.7.33-hotfixes.0
|
|
143
150
|
|
|
144
151
|
## 0.7.31
|
|
145
152
|
|
|
146
153
|
### Patch Changes
|
|
147
154
|
|
|
148
|
-
-
|
|
149
|
-
|
|
155
|
+
- Updated dependencies
|
|
156
|
+
- cojson@0.7.31
|
|
150
157
|
|
|
151
158
|
## 0.7.29
|
|
152
159
|
|
|
153
160
|
### Patch Changes
|
|
154
161
|
|
|
155
|
-
-
|
|
156
|
-
|
|
162
|
+
- Updated dependencies
|
|
163
|
+
- cojson@0.7.29
|
|
157
164
|
|
|
158
165
|
## 0.7.28
|
|
159
166
|
|
|
160
167
|
### Patch Changes
|
|
161
168
|
|
|
162
|
-
-
|
|
163
|
-
|
|
169
|
+
- Updated dependencies
|
|
170
|
+
- cojson@0.7.28
|
|
164
171
|
|
|
165
172
|
## 0.7.26
|
|
166
173
|
|
|
167
174
|
### Patch Changes
|
|
168
175
|
|
|
169
|
-
-
|
|
170
|
-
-
|
|
171
|
-
|
|
176
|
+
- Remove Effect from jazz/cojson internals
|
|
177
|
+
- Updated dependencies
|
|
178
|
+
- cojson@0.7.26
|
|
172
179
|
|
|
173
180
|
## 0.7.23
|
|
174
181
|
|
|
175
182
|
### Patch Changes
|
|
176
183
|
|
|
177
|
-
-
|
|
178
|
-
|
|
184
|
+
- Updated dependencies
|
|
185
|
+
- cojson@0.7.23
|
|
179
186
|
|
|
180
187
|
## 0.7.18
|
|
181
188
|
|
|
182
189
|
### Patch Changes
|
|
183
190
|
|
|
184
|
-
-
|
|
185
|
-
|
|
191
|
+
- Updated dependencies
|
|
192
|
+
- cojson@0.7.18
|
|
186
193
|
|
|
187
194
|
## 0.7.17
|
|
188
195
|
|
|
189
196
|
### Patch Changes
|
|
190
197
|
|
|
191
|
-
-
|
|
192
|
-
|
|
198
|
+
- Updated dependencies
|
|
199
|
+
- cojson@0.7.17
|
|
193
200
|
|
|
194
201
|
## 0.7.14
|
|
195
202
|
|
|
196
203
|
### Patch Changes
|
|
197
204
|
|
|
198
|
-
-
|
|
199
|
-
|
|
205
|
+
- Updated dependencies
|
|
206
|
+
- cojson@0.7.14
|
|
200
207
|
|
|
201
208
|
## 0.7.11
|
|
202
209
|
|
|
203
210
|
### Patch Changes
|
|
204
211
|
|
|
205
|
-
-
|
|
206
|
-
|
|
212
|
+
- Updated dependencies
|
|
213
|
+
- cojson@0.7.11
|
|
207
214
|
|
|
208
215
|
## 0.7.10
|
|
209
216
|
|
|
210
217
|
### Patch Changes
|
|
211
218
|
|
|
212
|
-
-
|
|
213
|
-
|
|
219
|
+
- Updated dependencies
|
|
220
|
+
- cojson@0.7.10
|
|
214
221
|
|
|
215
222
|
## 0.7.9
|
|
216
223
|
|
|
217
224
|
### Patch Changes
|
|
218
225
|
|
|
219
|
-
-
|
|
220
|
-
|
|
226
|
+
- Updated dependencies
|
|
227
|
+
- cojson@0.7.9
|
|
221
228
|
|
|
222
229
|
## 0.7.0
|
|
223
230
|
|
|
224
231
|
### Patch Changes
|
|
225
232
|
|
|
226
|
-
-
|
|
227
|
-
-
|
|
228
|
-
-
|
|
229
|
-
-
|
|
230
|
-
-
|
|
231
|
-
-
|
|
232
|
-
-
|
|
233
|
-
-
|
|
234
|
-
-
|
|
235
|
-
-
|
|
236
|
-
-
|
|
237
|
-
-
|
|
238
|
-
-
|
|
239
|
-
-
|
|
240
|
-
-
|
|
241
|
-
-
|
|
242
|
-
-
|
|
243
|
-
-
|
|
244
|
-
-
|
|
245
|
-
-
|
|
246
|
-
-
|
|
247
|
-
-
|
|
248
|
-
-
|
|
249
|
-
-
|
|
250
|
-
|
|
233
|
+
- c4151fc: Support stricter TS lint rules
|
|
234
|
+
- 952982e: Consistent proxy based API
|
|
235
|
+
- 21771c4: Reintroduce changes from main
|
|
236
|
+
- 69ac514: Use effect schema much less
|
|
237
|
+
- f0f6f1b: Clean up API more & re-add jazz-nodejs
|
|
238
|
+
- 1a44f87: Refactoring
|
|
239
|
+
- 627d895: Get rid of Co namespace
|
|
240
|
+
- Updated dependencies [1a35307]
|
|
241
|
+
- Updated dependencies [96c494f]
|
|
242
|
+
- Updated dependencies [19f52b7]
|
|
243
|
+
- Updated dependencies [d8fe2b1]
|
|
244
|
+
- Updated dependencies [1200aae]
|
|
245
|
+
- Updated dependencies [52675c9]
|
|
246
|
+
- Updated dependencies [1a35307]
|
|
247
|
+
- Updated dependencies [e299c3e]
|
|
248
|
+
- Updated dependencies [bf0f8ec]
|
|
249
|
+
- Updated dependencies [c4151fc]
|
|
250
|
+
- Updated dependencies [8636319]
|
|
251
|
+
- Updated dependencies [952982e]
|
|
252
|
+
- Updated dependencies [21771c4]
|
|
253
|
+
- Updated dependencies [69ac514]
|
|
254
|
+
- Updated dependencies [f0f6f1b]
|
|
255
|
+
- Updated dependencies [1a44f87]
|
|
256
|
+
- Updated dependencies [63374cc]
|
|
257
|
+
- cojson@0.7.0
|
|
251
258
|
|
|
252
259
|
## 0.7.0-alpha.42
|
|
253
260
|
|
|
254
261
|
### Patch Changes
|
|
255
262
|
|
|
256
|
-
-
|
|
257
|
-
|
|
263
|
+
- Updated dependencies
|
|
264
|
+
- cojson@0.7.0-alpha.42
|
|
258
265
|
|
|
259
266
|
## 0.7.0-alpha.39
|
|
260
267
|
|
|
261
268
|
### Patch Changes
|
|
262
269
|
|
|
263
|
-
-
|
|
264
|
-
|
|
270
|
+
- Updated dependencies
|
|
271
|
+
- cojson@0.7.0-alpha.39
|
|
265
272
|
|
|
266
273
|
## 0.7.0-alpha.38
|
|
267
274
|
|
|
268
275
|
### Patch Changes
|
|
269
276
|
|
|
270
|
-
-
|
|
271
|
-
|
|
277
|
+
- Updated dependencies
|
|
278
|
+
- cojson@0.7.0-alpha.38
|
|
272
279
|
|
|
273
280
|
## 0.7.0-alpha.37
|
|
274
281
|
|
|
275
282
|
### Patch Changes
|
|
276
283
|
|
|
277
|
-
-
|
|
278
|
-
|
|
284
|
+
- Updated dependencies
|
|
285
|
+
- cojson@0.7.0-alpha.37
|
|
279
286
|
|
|
280
287
|
## 0.7.0-alpha.36
|
|
281
288
|
|
|
282
289
|
### Patch Changes
|
|
283
290
|
|
|
284
|
-
-
|
|
285
|
-
-
|
|
286
|
-
|
|
291
|
+
- Updated dependencies [1a35307]
|
|
292
|
+
- Updated dependencies [1a35307]
|
|
293
|
+
- cojson@0.7.0-alpha.36
|
|
287
294
|
|
|
288
295
|
## 0.7.0-alpha.35
|
|
289
296
|
|
|
290
297
|
### Patch Changes
|
|
291
298
|
|
|
292
|
-
-
|
|
293
|
-
|
|
299
|
+
- Updated dependencies
|
|
300
|
+
- cojson@0.7.0-alpha.35
|
|
294
301
|
|
|
295
302
|
## 0.7.0-alpha.29
|
|
296
303
|
|
|
297
304
|
### Patch Changes
|
|
298
305
|
|
|
299
|
-
-
|
|
300
|
-
-
|
|
301
|
-
|
|
306
|
+
- Reintroduce changes from main
|
|
307
|
+
- Updated dependencies
|
|
308
|
+
- cojson@0.7.0-alpha.29
|
|
302
309
|
|
|
303
310
|
## 0.7.0-alpha.28
|
|
304
311
|
|
|
305
312
|
### Patch Changes
|
|
306
313
|
|
|
307
|
-
-
|
|
308
|
-
|
|
314
|
+
- Updated dependencies
|
|
315
|
+
- cojson@0.7.0-alpha.28
|
|
309
316
|
|
|
310
317
|
## 0.7.0-alpha.27
|
|
311
318
|
|
|
312
319
|
### Patch Changes
|
|
313
320
|
|
|
314
|
-
-
|
|
315
|
-
|
|
321
|
+
- Updated dependencies
|
|
322
|
+
- cojson@0.7.0-alpha.27
|
|
316
323
|
|
|
317
324
|
## 0.7.0-alpha.24
|
|
318
325
|
|
|
319
326
|
### Patch Changes
|
|
320
327
|
|
|
321
|
-
-
|
|
322
|
-
|
|
328
|
+
- Updated dependencies
|
|
329
|
+
- cojson@0.7.0-alpha.24
|
|
323
330
|
|
|
324
331
|
## 0.7.0-alpha.11
|
|
325
332
|
|
|
326
333
|
### Patch Changes
|
|
327
334
|
|
|
328
|
-
-
|
|
329
|
-
-
|
|
330
|
-
|
|
335
|
+
- Support stricter TS lint rules
|
|
336
|
+
- Updated dependencies
|
|
337
|
+
- cojson@0.7.0-alpha.11
|
|
331
338
|
|
|
332
339
|
## 0.7.0-alpha.10
|
|
333
340
|
|
|
334
341
|
### Patch Changes
|
|
335
342
|
|
|
336
|
-
-
|
|
337
|
-
-
|
|
338
|
-
|
|
343
|
+
- Clean up API more & re-add jazz-nodejs
|
|
344
|
+
- Updated dependencies
|
|
345
|
+
- cojson@0.7.0-alpha.10
|
|
339
346
|
|
|
340
347
|
## 0.6.4-alpha.4
|
|
341
348
|
|
|
342
349
|
### Patch Changes
|
|
343
350
|
|
|
344
|
-
-
|
|
345
|
-
-
|
|
346
|
-
|
|
351
|
+
- Consistent proxy based API
|
|
352
|
+
- Updated dependencies
|
|
353
|
+
- cojson@0.7.0-alpha.7
|
|
347
354
|
|
|
348
355
|
## 0.6.4-alpha.3
|
|
349
356
|
|
|
350
357
|
### Patch Changes
|
|
351
358
|
|
|
352
|
-
-
|
|
353
|
-
-
|
|
354
|
-
|
|
359
|
+
- Refactoring
|
|
360
|
+
- Updated dependencies
|
|
361
|
+
- cojson@0.7.0-alpha.5
|
|
355
362
|
|
|
356
363
|
## 0.6.4-alpha.2
|
|
357
364
|
|
|
358
365
|
### Patch Changes
|
|
359
366
|
|
|
360
|
-
-
|
|
367
|
+
- Get rid of Co namespace
|
|
361
368
|
|
|
362
369
|
## 0.6.4-alpha.1
|
|
363
370
|
|
|
364
371
|
### Patch Changes
|
|
365
372
|
|
|
366
|
-
-
|
|
367
|
-
-
|
|
368
|
-
|
|
373
|
+
- Use effect schema much less
|
|
374
|
+
- Updated dependencies
|
|
375
|
+
- cojson@0.7.0-alpha.1
|
|
369
376
|
|
|
370
377
|
## 0.6.4-alpha.0
|
|
371
378
|
|
|
372
379
|
### Patch Changes
|
|
373
380
|
|
|
374
|
-
-
|
|
375
|
-
|
|
381
|
+
- Updated dependencies
|
|
382
|
+
- cojson@0.7.0-alpha.0
|
|
376
383
|
|
|
377
384
|
## 0.6.3
|
|
378
385
|
|
|
379
386
|
### Patch Changes
|
|
380
387
|
|
|
381
|
-
-
|
|
388
|
+
- Fix ordering bugs with indexeddb
|
|
382
389
|
|
|
383
390
|
## 0.6.2
|
|
384
391
|
|
|
385
392
|
### Patch Changes
|
|
386
393
|
|
|
387
|
-
-
|
|
394
|
+
- Fix TypeScript lint
|
|
388
395
|
|
|
389
396
|
## 0.6.1
|
|
390
397
|
|
|
391
398
|
### Patch Changes
|
|
392
399
|
|
|
393
|
-
-
|
|
394
|
-
-
|
|
395
|
-
|
|
400
|
+
- IndexedDB & timer perf improvements
|
|
401
|
+
- Updated dependencies
|
|
402
|
+
- cojson@0.6.4
|
|
396
403
|
|
|
397
404
|
## 0.6.0
|
|
398
405
|
|
|
399
406
|
### Minor Changes
|
|
400
407
|
|
|
401
|
-
-
|
|
408
|
+
- Make addMember and removeMember take loaded Accounts instead of just IDs
|
|
402
409
|
|
|
403
410
|
### Patch Changes
|
|
404
411
|
|
|
405
|
-
-
|
|
406
|
-
|
|
412
|
+
- Updated dependencies
|
|
413
|
+
- cojson@0.6.0
|
|
407
414
|
|
|
408
415
|
## 0.5.0
|
|
409
416
|
|
|
410
417
|
### Minor Changes
|
|
411
418
|
|
|
412
|
-
-
|
|
419
|
+
- Adding a lot of performance improvements to cojson, add a stresstest for the twit example and make that run smoother in a lot of ways.
|
|
413
420
|
|
|
414
421
|
### Patch Changes
|
|
415
422
|
|
|
416
|
-
-
|
|
417
|
-
|
|
423
|
+
- Updated dependencies
|
|
424
|
+
- cojson@0.5.0
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MAX_RECOMMENDED_TX_SIZE, cojsonInternals, } from "cojson";
|
|
2
2
|
import { SyncPromise } from "./syncPromises.js";
|
|
3
3
|
export class IDBStorage {
|
|
4
4
|
constructor(db, fromLocalNode, toLocalNode) {
|
|
@@ -149,9 +149,7 @@ export class IDBStorage {
|
|
|
149
149
|
return this.makeRequest(({ coValues }) => coValues.index("coValuesById").get(theirKnown.id))
|
|
150
150
|
.then((coValueRow) => {
|
|
151
151
|
return (coValueRow
|
|
152
|
-
? this.makeRequest(({ sessions }) => sessions
|
|
153
|
-
.index("sessionsByCoValue")
|
|
154
|
-
.getAll(coValueRow.rowID))
|
|
152
|
+
? this.makeRequest(({ sessions }) => sessions.index("sessionsByCoValue").getAll(coValueRow.rowID))
|
|
155
153
|
: SyncPromise.resolve([])).then((allOurSessions) => {
|
|
156
154
|
const ourKnown = {
|
|
157
155
|
id: theirKnown.id,
|
|
@@ -162,36 +160,23 @@ export class IDBStorage {
|
|
|
162
160
|
{
|
|
163
161
|
action: "content",
|
|
164
162
|
id: theirKnown.id,
|
|
165
|
-
header: theirKnown.header
|
|
166
|
-
? undefined
|
|
167
|
-
: coValueRow?.header,
|
|
163
|
+
header: theirKnown.header ? undefined : coValueRow?.header,
|
|
168
164
|
new: {},
|
|
169
165
|
priority: cojsonInternals.getPriorityFromHeader(coValueRow?.header),
|
|
170
166
|
},
|
|
171
167
|
];
|
|
172
168
|
return SyncPromise.all(allOurSessions.map((sessionRow) => {
|
|
173
|
-
ourKnown.sessions[sessionRow.sessionID] =
|
|
174
|
-
sessionRow.lastIdx;
|
|
169
|
+
ourKnown.sessions[sessionRow.sessionID] = sessionRow.lastIdx;
|
|
175
170
|
if (sessionRow.lastIdx >
|
|
176
171
|
(theirKnown.sessions[sessionRow.sessionID] || 0)) {
|
|
177
|
-
const firstNewTxIdx = theirKnown.sessions[sessionRow.sessionID] ||
|
|
178
|
-
|
|
179
|
-
return this.makeRequest(({ signatureAfter }) => signatureAfter.getAll(IDBKeyRange.bound([
|
|
180
|
-
sessionRow.rowID,
|
|
181
|
-
firstNewTxIdx,
|
|
182
|
-
], [sessionRow.rowID, Infinity]))).then((signaturesAndIdxs) => {
|
|
172
|
+
const firstNewTxIdx = theirKnown.sessions[sessionRow.sessionID] || 0;
|
|
173
|
+
return this.makeRequest(({ signatureAfter }) => signatureAfter.getAll(IDBKeyRange.bound([sessionRow.rowID, firstNewTxIdx], [sessionRow.rowID, Infinity]))).then((signaturesAndIdxs) => {
|
|
183
174
|
// console.log(
|
|
184
175
|
// theirKnown.id,
|
|
185
176
|
// "signaturesAndIdxs",
|
|
186
177
|
// JSON.stringify(signaturesAndIdxs)
|
|
187
178
|
// );
|
|
188
|
-
return this.makeRequest(({ transactions }) => transactions.getAll(IDBKeyRange.bound([
|
|
189
|
-
sessionRow.rowID,
|
|
190
|
-
firstNewTxIdx,
|
|
191
|
-
], [
|
|
192
|
-
sessionRow.rowID,
|
|
193
|
-
Infinity,
|
|
194
|
-
]))).then((newTxsInSession) => {
|
|
179
|
+
return this.makeRequest(({ transactions }) => transactions.getAll(IDBKeyRange.bound([sessionRow.rowID, firstNewTxIdx], [sessionRow.rowID, Infinity]))).then((newTxsInSession) => {
|
|
195
180
|
collectNewTxs(newTxsInSession, newContentPieces, sessionRow, signaturesAndIdxs, theirKnown, firstNewTxIdx);
|
|
196
181
|
});
|
|
197
182
|
});
|
|
@@ -215,8 +200,7 @@ export class IDBStorage {
|
|
|
215
200
|
asDependencyOf,
|
|
216
201
|
})
|
|
217
202
|
.catch((e) => console.error("Error sending known state", e));
|
|
218
|
-
const nonEmptyNewContentPieces = newContentPieces.filter((piece) => piece.header ||
|
|
219
|
-
Object.keys(piece.new).length > 0);
|
|
203
|
+
const nonEmptyNewContentPieces = newContentPieces.filter((piece) => piece.header || Object.keys(piece.new).length > 0);
|
|
220
204
|
// console.log(theirKnown.id, nonEmptyNewContentPieces);
|
|
221
205
|
for (const piece of nonEmptyNewContentPieces) {
|
|
222
206
|
this.toLocalNode
|
|
@@ -262,13 +246,8 @@ export class IDBStorage {
|
|
|
262
246
|
}
|
|
263
247
|
})
|
|
264
248
|
.then((storedCoValueRowID) => {
|
|
265
|
-
void this.makeRequest(({ sessions }) => sessions
|
|
266
|
-
.
|
|
267
|
-
.getAll(storedCoValueRowID)).then((allOurSessionsEntries) => {
|
|
268
|
-
const allOurSessions = Object.fromEntries(allOurSessionsEntries.map((row) => [
|
|
269
|
-
row.sessionID,
|
|
270
|
-
row,
|
|
271
|
-
]));
|
|
249
|
+
void this.makeRequest(({ sessions }) => sessions.index("sessionsByCoValue").getAll(storedCoValueRowID)).then((allOurSessionsEntries) => {
|
|
250
|
+
const allOurSessions = Object.fromEntries(allOurSessionsEntries.map((row) => [row.sessionID, row]));
|
|
272
251
|
const ourKnown = {
|
|
273
252
|
id: msg.id,
|
|
274
253
|
header: true,
|
|
@@ -278,11 +257,9 @@ export class IDBStorage {
|
|
|
278
257
|
return Promise.all(Object.keys(msg.new).map((sessionID) => {
|
|
279
258
|
const sessionRow = allOurSessions[sessionID];
|
|
280
259
|
if (sessionRow) {
|
|
281
|
-
ourKnown.sessions[sessionRow.sessionID] =
|
|
282
|
-
sessionRow.lastIdx;
|
|
260
|
+
ourKnown.sessions[sessionRow.sessionID] = sessionRow.lastIdx;
|
|
283
261
|
}
|
|
284
|
-
if ((sessionRow?.lastIdx || 0) <
|
|
285
|
-
(msg.new[sessionID]?.after || 0)) {
|
|
262
|
+
if ((sessionRow?.lastIdx || 0) < (msg.new[sessionID]?.after || 0)) {
|
|
286
263
|
invalidAssumptions = true;
|
|
287
264
|
}
|
|
288
265
|
else {
|
|
@@ -372,7 +349,8 @@ function collectNewTxs(newTxsInSession, newContentPieces, sessionRow, signatures
|
|
|
372
349
|
lastSignature: "WILL_BE_REPLACED",
|
|
373
350
|
newTransactions: [],
|
|
374
351
|
};
|
|
375
|
-
newContentPieces[newContentPieces.length - 1].new[sessionRow.sessionID] =
|
|
352
|
+
newContentPieces[newContentPieces.length - 1].new[sessionRow.sessionID] =
|
|
353
|
+
sessionEntry;
|
|
376
354
|
}
|
|
377
355
|
sessionEntry.newTransactions.push(tx.tx);
|
|
378
356
|
if (signaturesAndIdxs[0] && idx === signaturesAndIdxs[0].idx) {
|
|
@@ -407,8 +385,7 @@ function getDependedOnCoValues(coValueRow, newContentPieces, theirKnown) {
|
|
|
407
385
|
change.op === "set" &&
|
|
408
386
|
"key" in change &&
|
|
409
387
|
change.key)
|
|
410
|
-
.filter((key) => typeof key === "string" &&
|
|
411
|
-
key.startsWith("co_"));
|
|
388
|
+
.filter((key) => typeof key === "string" && key.startsWith("co_"));
|
|
412
389
|
}))
|
|
413
390
|
: coValueRow?.header.ruleset.type === "ownedByGroup"
|
|
414
391
|
? [
|