cojson-storage-sqlite 0.8.12 → 0.8.17
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 +151 -137
- package/dist/index.js +13 -22
- package/dist/index.js.map +1 -1
- package/package.json +5 -9
- package/src/index.ts +532 -565
- package/tsconfig.json +2 -2
- package/.eslintrc.cjs +0 -24
- package/.prettierrc.js +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,381 +1,395 @@
|
|
|
1
1
|
# cojson-storage-sqlite
|
|
2
2
|
|
|
3
|
+
## 0.8.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [d433cf4]
|
|
8
|
+
- cojson@0.8.17
|
|
9
|
+
|
|
10
|
+
## 0.8.16
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [b934fab]
|
|
15
|
+
- cojson@0.8.16
|
|
16
|
+
|
|
3
17
|
## 0.8.12
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
6
20
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
|
|
21
|
+
- 6ed75eb: Introduce "storage" peer role
|
|
22
|
+
- Updated dependencies [6ed75eb]
|
|
23
|
+
- cojson@0.8.12
|
|
10
24
|
|
|
11
25
|
## 0.8.11
|
|
12
26
|
|
|
13
27
|
### Patch Changes
|
|
14
28
|
|
|
15
|
-
-
|
|
16
|
-
|
|
29
|
+
- Updated dependencies [1ed4ab5]
|
|
30
|
+
- cojson@0.8.11
|
|
17
31
|
|
|
18
32
|
## 0.8.5
|
|
19
33
|
|
|
20
34
|
### Patch Changes
|
|
21
35
|
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
|
|
36
|
+
- Updated dependencies [c3f4e6b]
|
|
37
|
+
- Updated dependencies [d9152ed]
|
|
38
|
+
- cojson@0.8.5
|
|
25
39
|
|
|
26
40
|
## 0.8.3
|
|
27
41
|
|
|
28
42
|
### Patch Changes
|
|
29
43
|
|
|
30
|
-
-
|
|
31
|
-
|
|
44
|
+
- Updated dependencies
|
|
45
|
+
- cojson@0.8.3
|
|
32
46
|
|
|
33
47
|
## 0.8.0
|
|
34
48
|
|
|
35
49
|
### Patch Changes
|
|
36
50
|
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
|
|
51
|
+
- Updated dependencies [6a147c2]
|
|
52
|
+
- Updated dependencies [ad40b88]
|
|
53
|
+
- cojson@0.8.0
|
|
40
54
|
|
|
41
55
|
## 0.7.35
|
|
42
56
|
|
|
43
57
|
### Patch Changes
|
|
44
58
|
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
|
|
59
|
+
- f350e90: Added a priority system for the sync messages
|
|
60
|
+
- Updated dependencies [35bbcd9]
|
|
61
|
+
- Updated dependencies [f350e90]
|
|
62
|
+
- cojson@0.7.35
|
|
49
63
|
|
|
50
64
|
## 0.7.34
|
|
51
65
|
|
|
52
66
|
### Patch Changes
|
|
53
67
|
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
|
|
68
|
+
- Updated dependencies [5d91f9f]
|
|
69
|
+
- Updated dependencies [5094e6d]
|
|
70
|
+
- Updated dependencies [b09589b]
|
|
71
|
+
- Updated dependencies [2c3a40c]
|
|
72
|
+
- Updated dependencies [4e16575]
|
|
73
|
+
- Updated dependencies [ea882ab]
|
|
74
|
+
- cojson@0.7.34
|
|
61
75
|
|
|
62
76
|
## 0.7.34-neverthrow.8
|
|
63
77
|
|
|
64
78
|
### Patch Changes
|
|
65
79
|
|
|
66
|
-
-
|
|
67
|
-
|
|
80
|
+
- Updated dependencies
|
|
81
|
+
- cojson@0.7.34-neverthrow.8
|
|
68
82
|
|
|
69
83
|
## 0.7.34-neverthrow.7
|
|
70
84
|
|
|
71
85
|
### Patch Changes
|
|
72
86
|
|
|
73
|
-
-
|
|
74
|
-
|
|
87
|
+
- Updated dependencies
|
|
88
|
+
- cojson@0.7.34-neverthrow.7
|
|
75
89
|
|
|
76
90
|
## 0.7.34-neverthrow.4
|
|
77
91
|
|
|
78
92
|
### Patch Changes
|
|
79
93
|
|
|
80
|
-
-
|
|
81
|
-
|
|
94
|
+
- Updated dependencies
|
|
95
|
+
- cojson@0.7.34-neverthrow.4
|
|
82
96
|
|
|
83
97
|
## 0.7.34-neverthrow.3
|
|
84
98
|
|
|
85
99
|
### Patch Changes
|
|
86
100
|
|
|
87
|
-
-
|
|
88
|
-
|
|
101
|
+
- Updated dependencies
|
|
102
|
+
- cojson@0.7.34-neverthrow.3
|
|
89
103
|
|
|
90
104
|
## 0.7.34-neverthrow.1
|
|
91
105
|
|
|
92
106
|
### Patch Changes
|
|
93
107
|
|
|
94
|
-
-
|
|
95
|
-
|
|
108
|
+
- Updated dependencies
|
|
109
|
+
- cojson@0.7.34-neverthrow.1
|
|
96
110
|
|
|
97
111
|
## 0.7.34-neverthrow.0
|
|
98
112
|
|
|
99
113
|
### Patch Changes
|
|
100
114
|
|
|
101
|
-
-
|
|
102
|
-
|
|
115
|
+
- Updated dependencies
|
|
116
|
+
- cojson@0.7.34-neverthrow.0
|
|
103
117
|
|
|
104
118
|
## 0.7.33
|
|
105
119
|
|
|
106
120
|
### Patch Changes
|
|
107
121
|
|
|
108
|
-
-
|
|
109
|
-
-
|
|
110
|
-
-
|
|
111
|
-
-
|
|
112
|
-
-
|
|
113
|
-
|
|
122
|
+
- 3bf5127: Allow crashing whole node on peer errors
|
|
123
|
+
- Updated dependencies [b297c93]
|
|
124
|
+
- Updated dependencies [3bf5127]
|
|
125
|
+
- Updated dependencies [a8b74ff]
|
|
126
|
+
- Updated dependencies [db53161]
|
|
127
|
+
- cojson@0.7.33
|
|
114
128
|
|
|
115
129
|
## 0.7.33-hotfixes.6
|
|
116
130
|
|
|
117
131
|
### Patch Changes
|
|
118
132
|
|
|
119
|
-
-
|
|
133
|
+
- Get rid of simulated errors
|
|
120
134
|
|
|
121
135
|
## 0.7.33-hotfixes.5
|
|
122
136
|
|
|
123
137
|
### Patch Changes
|
|
124
138
|
|
|
125
|
-
-
|
|
126
|
-
-
|
|
127
|
-
|
|
139
|
+
- Make simulated errors even more likely
|
|
140
|
+
- Updated dependencies
|
|
141
|
+
- cojson@0.7.33-hotfixes.5
|
|
128
142
|
|
|
129
143
|
## 0.7.33-hotfixes.4
|
|
130
144
|
|
|
131
145
|
### Patch Changes
|
|
132
146
|
|
|
133
|
-
-
|
|
134
|
-
|
|
147
|
+
- Updated dependencies
|
|
148
|
+
- cojson@0.7.33-hotfixes.4
|
|
135
149
|
|
|
136
150
|
## 0.7.33-hotfixes.3
|
|
137
151
|
|
|
138
152
|
### Patch Changes
|
|
139
153
|
|
|
140
|
-
-
|
|
141
|
-
-
|
|
142
|
-
|
|
154
|
+
- Allow crashing whole node on peer errors
|
|
155
|
+
- Updated dependencies
|
|
156
|
+
- cojson@0.7.33-hotfixes.3
|
|
143
157
|
|
|
144
158
|
## 0.7.33-hotfixes.0
|
|
145
159
|
|
|
146
160
|
### Patch Changes
|
|
147
161
|
|
|
148
|
-
-
|
|
149
|
-
|
|
162
|
+
- Updated dependencies
|
|
163
|
+
- cojson@0.7.33-hotfixes.0
|
|
150
164
|
|
|
151
165
|
## 0.7.31
|
|
152
166
|
|
|
153
167
|
### Patch Changes
|
|
154
168
|
|
|
155
|
-
-
|
|
156
|
-
|
|
169
|
+
- Updated dependencies
|
|
170
|
+
- cojson@0.7.31
|
|
157
171
|
|
|
158
172
|
## 0.7.29
|
|
159
173
|
|
|
160
174
|
### Patch Changes
|
|
161
175
|
|
|
162
|
-
-
|
|
163
|
-
|
|
176
|
+
- Updated dependencies
|
|
177
|
+
- cojson@0.7.29
|
|
164
178
|
|
|
165
179
|
## 0.7.28
|
|
166
180
|
|
|
167
181
|
### Patch Changes
|
|
168
182
|
|
|
169
|
-
-
|
|
170
|
-
|
|
183
|
+
- Updated dependencies
|
|
184
|
+
- cojson@0.7.28
|
|
171
185
|
|
|
172
186
|
## 0.7.26
|
|
173
187
|
|
|
174
188
|
### Patch Changes
|
|
175
189
|
|
|
176
|
-
-
|
|
177
|
-
-
|
|
178
|
-
|
|
190
|
+
- Remove Effect from jazz/cojson internals
|
|
191
|
+
- Updated dependencies
|
|
192
|
+
- cojson@0.7.26
|
|
179
193
|
|
|
180
194
|
## 0.7.23
|
|
181
195
|
|
|
182
196
|
### Patch Changes
|
|
183
197
|
|
|
184
|
-
-
|
|
185
|
-
|
|
198
|
+
- Updated dependencies
|
|
199
|
+
- cojson@0.7.23
|
|
186
200
|
|
|
187
201
|
## 0.7.18
|
|
188
202
|
|
|
189
203
|
### Patch Changes
|
|
190
204
|
|
|
191
|
-
-
|
|
192
|
-
|
|
205
|
+
- Updated dependencies
|
|
206
|
+
- cojson@0.7.18
|
|
193
207
|
|
|
194
208
|
## 0.7.17
|
|
195
209
|
|
|
196
210
|
### Patch Changes
|
|
197
211
|
|
|
198
|
-
-
|
|
199
|
-
|
|
212
|
+
- Updated dependencies
|
|
213
|
+
- cojson@0.7.17
|
|
200
214
|
|
|
201
215
|
## 0.7.14
|
|
202
216
|
|
|
203
217
|
### Patch Changes
|
|
204
218
|
|
|
205
|
-
-
|
|
206
|
-
|
|
219
|
+
- Updated dependencies
|
|
220
|
+
- cojson@0.7.14
|
|
207
221
|
|
|
208
222
|
## 0.7.11
|
|
209
223
|
|
|
210
224
|
### Patch Changes
|
|
211
225
|
|
|
212
|
-
-
|
|
213
|
-
|
|
226
|
+
- Updated dependencies
|
|
227
|
+
- cojson@0.7.11
|
|
214
228
|
|
|
215
229
|
## 0.7.10
|
|
216
230
|
|
|
217
231
|
### Patch Changes
|
|
218
232
|
|
|
219
|
-
-
|
|
220
|
-
|
|
233
|
+
- Updated dependencies
|
|
234
|
+
- cojson@0.7.10
|
|
221
235
|
|
|
222
236
|
## 0.7.9
|
|
223
237
|
|
|
224
238
|
### Patch Changes
|
|
225
239
|
|
|
226
|
-
-
|
|
227
|
-
|
|
240
|
+
- Updated dependencies
|
|
241
|
+
- cojson@0.7.9
|
|
228
242
|
|
|
229
243
|
## 0.7.0
|
|
230
244
|
|
|
231
245
|
### Patch Changes
|
|
232
246
|
|
|
233
|
-
-
|
|
234
|
-
-
|
|
235
|
-
-
|
|
236
|
-
-
|
|
237
|
-
-
|
|
238
|
-
-
|
|
239
|
-
-
|
|
240
|
-
-
|
|
241
|
-
-
|
|
242
|
-
-
|
|
243
|
-
-
|
|
244
|
-
-
|
|
245
|
-
-
|
|
246
|
-
-
|
|
247
|
-
-
|
|
248
|
-
-
|
|
249
|
-
-
|
|
250
|
-
-
|
|
251
|
-
-
|
|
252
|
-
-
|
|
253
|
-
-
|
|
254
|
-
|
|
247
|
+
- c4151fc: Support stricter TS lint rules
|
|
248
|
+
- 21771c4: Reintroduce changes from main
|
|
249
|
+
- 69ac514: Use effect schema much less
|
|
250
|
+
- f0f6f1b: Clean up API more & re-add jazz-nodejs
|
|
251
|
+
- Updated dependencies [1a35307]
|
|
252
|
+
- Updated dependencies [96c494f]
|
|
253
|
+
- Updated dependencies [19f52b7]
|
|
254
|
+
- Updated dependencies [d8fe2b1]
|
|
255
|
+
- Updated dependencies [1200aae]
|
|
256
|
+
- Updated dependencies [52675c9]
|
|
257
|
+
- Updated dependencies [1a35307]
|
|
258
|
+
- Updated dependencies [e299c3e]
|
|
259
|
+
- Updated dependencies [bf0f8ec]
|
|
260
|
+
- Updated dependencies [c4151fc]
|
|
261
|
+
- Updated dependencies [8636319]
|
|
262
|
+
- Updated dependencies [952982e]
|
|
263
|
+
- Updated dependencies [21771c4]
|
|
264
|
+
- Updated dependencies [69ac514]
|
|
265
|
+
- Updated dependencies [f0f6f1b]
|
|
266
|
+
- Updated dependencies [1a44f87]
|
|
267
|
+
- Updated dependencies [63374cc]
|
|
268
|
+
- cojson@0.7.0
|
|
255
269
|
|
|
256
270
|
## 0.7.0-alpha.42
|
|
257
271
|
|
|
258
272
|
### Patch Changes
|
|
259
273
|
|
|
260
|
-
-
|
|
261
|
-
|
|
274
|
+
- Updated dependencies
|
|
275
|
+
- cojson@0.7.0-alpha.42
|
|
262
276
|
|
|
263
277
|
## 0.7.0-alpha.39
|
|
264
278
|
|
|
265
279
|
### Patch Changes
|
|
266
280
|
|
|
267
|
-
-
|
|
268
|
-
|
|
281
|
+
- Updated dependencies
|
|
282
|
+
- cojson@0.7.0-alpha.39
|
|
269
283
|
|
|
270
284
|
## 0.7.0-alpha.38
|
|
271
285
|
|
|
272
286
|
### Patch Changes
|
|
273
287
|
|
|
274
|
-
-
|
|
275
|
-
|
|
288
|
+
- Updated dependencies
|
|
289
|
+
- cojson@0.7.0-alpha.38
|
|
276
290
|
|
|
277
291
|
## 0.7.0-alpha.37
|
|
278
292
|
|
|
279
293
|
### Patch Changes
|
|
280
294
|
|
|
281
|
-
-
|
|
282
|
-
|
|
295
|
+
- Updated dependencies
|
|
296
|
+
- cojson@0.7.0-alpha.37
|
|
283
297
|
|
|
284
298
|
## 0.7.0-alpha.36
|
|
285
299
|
|
|
286
300
|
### Patch Changes
|
|
287
301
|
|
|
288
|
-
-
|
|
289
|
-
-
|
|
290
|
-
|
|
302
|
+
- Updated dependencies [1a35307]
|
|
303
|
+
- Updated dependencies [1a35307]
|
|
304
|
+
- cojson@0.7.0-alpha.36
|
|
291
305
|
|
|
292
306
|
## 0.7.0-alpha.35
|
|
293
307
|
|
|
294
308
|
### Patch Changes
|
|
295
309
|
|
|
296
|
-
-
|
|
297
|
-
|
|
310
|
+
- Updated dependencies
|
|
311
|
+
- cojson@0.7.0-alpha.35
|
|
298
312
|
|
|
299
313
|
## 0.7.0-alpha.29
|
|
300
314
|
|
|
301
315
|
### Patch Changes
|
|
302
316
|
|
|
303
|
-
-
|
|
304
|
-
-
|
|
305
|
-
|
|
317
|
+
- Reintroduce changes from main
|
|
318
|
+
- Updated dependencies
|
|
319
|
+
- cojson@0.7.0-alpha.29
|
|
306
320
|
|
|
307
321
|
## 0.7.0-alpha.28
|
|
308
322
|
|
|
309
323
|
### Patch Changes
|
|
310
324
|
|
|
311
|
-
-
|
|
312
|
-
|
|
325
|
+
- Updated dependencies
|
|
326
|
+
- cojson@0.7.0-alpha.28
|
|
313
327
|
|
|
314
328
|
## 0.7.0-alpha.27
|
|
315
329
|
|
|
316
330
|
### Patch Changes
|
|
317
331
|
|
|
318
|
-
-
|
|
319
|
-
|
|
332
|
+
- Updated dependencies
|
|
333
|
+
- cojson@0.7.0-alpha.27
|
|
320
334
|
|
|
321
335
|
## 0.7.0-alpha.24
|
|
322
336
|
|
|
323
337
|
### Patch Changes
|
|
324
338
|
|
|
325
|
-
-
|
|
326
|
-
|
|
339
|
+
- Updated dependencies
|
|
340
|
+
- cojson@0.7.0-alpha.24
|
|
327
341
|
|
|
328
342
|
## 0.7.0-alpha.11
|
|
329
343
|
|
|
330
344
|
### Patch Changes
|
|
331
345
|
|
|
332
|
-
-
|
|
333
|
-
-
|
|
334
|
-
|
|
346
|
+
- Support stricter TS lint rules
|
|
347
|
+
- Updated dependencies
|
|
348
|
+
- cojson@0.7.0-alpha.11
|
|
335
349
|
|
|
336
350
|
## 0.7.0-alpha.10
|
|
337
351
|
|
|
338
352
|
### Patch Changes
|
|
339
353
|
|
|
340
|
-
-
|
|
341
|
-
-
|
|
342
|
-
|
|
354
|
+
- Clean up API more & re-add jazz-nodejs
|
|
355
|
+
- Updated dependencies
|
|
356
|
+
- cojson@0.7.0-alpha.10
|
|
343
357
|
|
|
344
358
|
## 0.5.3-alpha.1
|
|
345
359
|
|
|
346
360
|
### Patch Changes
|
|
347
361
|
|
|
348
|
-
-
|
|
349
|
-
-
|
|
350
|
-
|
|
362
|
+
- Use effect schema much less
|
|
363
|
+
- Updated dependencies
|
|
364
|
+
- cojson@0.7.0-alpha.1
|
|
351
365
|
|
|
352
366
|
## 0.5.3-alpha.0
|
|
353
367
|
|
|
354
368
|
### Patch Changes
|
|
355
369
|
|
|
356
|
-
-
|
|
357
|
-
|
|
370
|
+
- Updated dependencies
|
|
371
|
+
- cojson@0.7.0-alpha.0
|
|
358
372
|
|
|
359
373
|
## 0.5.2
|
|
360
374
|
|
|
361
375
|
### Patch Changes
|
|
362
376
|
|
|
363
|
-
-
|
|
364
|
-
|
|
377
|
+
- Updated dependencies
|
|
378
|
+
- cojson@0.6.0
|
|
365
379
|
|
|
366
380
|
## 0.5.1
|
|
367
381
|
|
|
368
382
|
### Patch Changes
|
|
369
383
|
|
|
370
|
-
-
|
|
384
|
+
- Make typedefs for better-sqlite3 a normal dependency
|
|
371
385
|
|
|
372
386
|
## 0.5.0
|
|
373
387
|
|
|
374
388
|
### Minor Changes
|
|
375
389
|
|
|
376
|
-
-
|
|
390
|
+
- 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.
|
|
377
391
|
|
|
378
392
|
### Patch Changes
|
|
379
393
|
|
|
380
|
-
-
|
|
381
|
-
|
|
394
|
+
- Updated dependencies
|
|
395
|
+
- 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 Database from "better-sqlite3";
|
|
3
3
|
export class SQLiteStorage {
|
|
4
4
|
constructor(db, fromLocalNode, toLocalNode) {
|
|
@@ -117,8 +117,7 @@ export class SQLiteStorage {
|
|
|
117
117
|
};
|
|
118
118
|
let parsedHeader;
|
|
119
119
|
try {
|
|
120
|
-
parsedHeader = (coValueRow?.header &&
|
|
121
|
-
JSON.parse(coValueRow.header));
|
|
120
|
+
parsedHeader = (coValueRow?.header && JSON.parse(coValueRow.header));
|
|
122
121
|
}
|
|
123
122
|
catch (e) {
|
|
124
123
|
console.warn(theirKnown.id, "Invalid JSON in header", e, coValueRow?.header);
|
|
@@ -136,8 +135,7 @@ export class SQLiteStorage {
|
|
|
136
135
|
];
|
|
137
136
|
for (const sessionRow of allOurSessions) {
|
|
138
137
|
ourKnown.sessions[sessionRow.sessionID] = sessionRow.lastIdx;
|
|
139
|
-
if (sessionRow.lastIdx >
|
|
140
|
-
(theirKnown.sessions[sessionRow.sessionID] || 0)) {
|
|
138
|
+
if (sessionRow.lastIdx > (theirKnown.sessions[sessionRow.sessionID] || 0)) {
|
|
141
139
|
const firstNewTxIdx = theirKnown.sessions[sessionRow.sessionID] || 0;
|
|
142
140
|
const signaturesAndIdxs = this.db
|
|
143
141
|
.prepare(`SELECT * FROM signatureAfter WHERE ses = ? AND idx >= ?`)
|
|
@@ -175,10 +173,8 @@ export class SQLiteStorage {
|
|
|
175
173
|
break;
|
|
176
174
|
}
|
|
177
175
|
sessionEntry.newTransactions.push(parsedTx);
|
|
178
|
-
if (signaturesAndIdxs[0] &&
|
|
179
|
-
|
|
180
|
-
sessionEntry.lastSignature =
|
|
181
|
-
signaturesAndIdxs[0].signature;
|
|
176
|
+
if (signaturesAndIdxs[0] && idx === signaturesAndIdxs[0].idx) {
|
|
177
|
+
sessionEntry.lastSignature = signaturesAndIdxs[0].signature;
|
|
182
178
|
signaturesAndIdxs.shift();
|
|
183
179
|
newContentPieces.push({
|
|
184
180
|
action: "content",
|
|
@@ -187,8 +183,7 @@ export class SQLiteStorage {
|
|
|
187
183
|
priority,
|
|
188
184
|
});
|
|
189
185
|
}
|
|
190
|
-
else if (idx ===
|
|
191
|
-
firstNewTxIdx + newTxInSession.length - 1) {
|
|
186
|
+
else if (idx === firstNewTxIdx + newTxInSession.length - 1) {
|
|
192
187
|
sessionEntry.lastSignature = sessionRow.lastSignature;
|
|
193
188
|
}
|
|
194
189
|
idx += 1;
|
|
@@ -217,15 +212,15 @@ export class SQLiteStorage {
|
|
|
217
212
|
change.op === "set" &&
|
|
218
213
|
"key" in change &&
|
|
219
214
|
change.key)
|
|
220
|
-
.filter((key) => typeof key === "string" &&
|
|
221
|
-
key.startsWith("co_"));
|
|
215
|
+
.filter((key) => typeof key === "string" && key.startsWith("co_"));
|
|
222
216
|
}))
|
|
223
217
|
: parsedHeader?.ruleset.type === "ownedByGroup"
|
|
224
218
|
? [
|
|
225
219
|
parsedHeader?.ruleset.group,
|
|
226
220
|
...new Set(newContentPieces.flatMap((piece) => Object.keys(piece)
|
|
227
221
|
.map((sessionID) => cojsonInternals.accountOrAgentIDfromSessionID(sessionID))
|
|
228
|
-
.filter((accountID) => cojsonInternals.isAccountID(accountID) &&
|
|
222
|
+
.filter((accountID) => cojsonInternals.isAccountID(accountID) &&
|
|
223
|
+
accountID !== theirKnown.id))),
|
|
229
224
|
]
|
|
230
225
|
: [];
|
|
231
226
|
for (const dependedOnCoValue of dependedOnCoValues) {
|
|
@@ -289,25 +284,21 @@ export class SQLiteStorage {
|
|
|
289
284
|
for (const sessionID of Object.keys(msg.new)) {
|
|
290
285
|
const sessionRow = allOurSessions[sessionID];
|
|
291
286
|
if (sessionRow) {
|
|
292
|
-
ourKnown.sessions[sessionRow.sessionID] =
|
|
293
|
-
sessionRow.lastIdx;
|
|
287
|
+
ourKnown.sessions[sessionRow.sessionID] = sessionRow.lastIdx;
|
|
294
288
|
}
|
|
295
|
-
if ((sessionRow?.lastIdx || 0) <
|
|
296
|
-
(msg.new[sessionID]?.after || 0)) {
|
|
289
|
+
if ((sessionRow?.lastIdx || 0) < (msg.new[sessionID]?.after || 0)) {
|
|
297
290
|
invalidAssumptions = true;
|
|
298
291
|
}
|
|
299
292
|
else {
|
|
300
293
|
const newTransactions = msg.new[sessionID]?.newTransactions || [];
|
|
301
|
-
const actuallyNewOffset = (sessionRow?.lastIdx || 0) -
|
|
302
|
-
(msg.new[sessionID]?.after || 0);
|
|
294
|
+
const actuallyNewOffset = (sessionRow?.lastIdx || 0) - (msg.new[sessionID]?.after || 0);
|
|
303
295
|
const actuallyNewTransactions = newTransactions.slice(actuallyNewOffset);
|
|
304
296
|
let newBytesSinceLastSignature = (sessionRow?.bytesSinceLastSignature || 0) +
|
|
305
297
|
actuallyNewTransactions.reduce((sum, tx) => sum +
|
|
306
298
|
(tx.privacy === "private"
|
|
307
299
|
? tx.encryptedChanges.length
|
|
308
300
|
: tx.changes.length), 0);
|
|
309
|
-
const newLastIdx = (sessionRow?.lastIdx || 0) +
|
|
310
|
-
actuallyNewTransactions.length;
|
|
301
|
+
const newLastIdx = (sessionRow?.lastIdx || 0) + actuallyNewTransactions.length;
|
|
311
302
|
let shouldWriteSignature = false;
|
|
312
303
|
if (newBytesSinceLastSignature > MAX_RECOMMENDED_TX_SIZE) {
|
|
313
304
|
shouldWriteSignature = true;
|