cojson-storage-sqlite 0.8.11 → 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 +149 -134
- package/dist/index.js +14 -23
- 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,373 +1,388 @@
|
|
|
1
1
|
# cojson-storage-sqlite
|
|
2
2
|
|
|
3
|
+
## 0.8.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [b934fab]
|
|
8
|
+
- cojson@0.8.16
|
|
9
|
+
|
|
10
|
+
## 0.8.12
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 6ed75eb: Introduce "storage" peer role
|
|
15
|
+
- Updated dependencies [6ed75eb]
|
|
16
|
+
- cojson@0.8.12
|
|
17
|
+
|
|
3
18
|
## 0.8.11
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
6
21
|
|
|
7
|
-
-
|
|
8
|
-
|
|
22
|
+
- Updated dependencies [1ed4ab5]
|
|
23
|
+
- cojson@0.8.11
|
|
9
24
|
|
|
10
25
|
## 0.8.5
|
|
11
26
|
|
|
12
27
|
### Patch Changes
|
|
13
28
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
|
|
29
|
+
- Updated dependencies [c3f4e6b]
|
|
30
|
+
- Updated dependencies [d9152ed]
|
|
31
|
+
- cojson@0.8.5
|
|
17
32
|
|
|
18
33
|
## 0.8.3
|
|
19
34
|
|
|
20
35
|
### Patch Changes
|
|
21
36
|
|
|
22
|
-
-
|
|
23
|
-
|
|
37
|
+
- Updated dependencies
|
|
38
|
+
- cojson@0.8.3
|
|
24
39
|
|
|
25
40
|
## 0.8.0
|
|
26
41
|
|
|
27
42
|
### Patch Changes
|
|
28
43
|
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
|
|
44
|
+
- Updated dependencies [6a147c2]
|
|
45
|
+
- Updated dependencies [ad40b88]
|
|
46
|
+
- cojson@0.8.0
|
|
32
47
|
|
|
33
48
|
## 0.7.35
|
|
34
49
|
|
|
35
50
|
### Patch Changes
|
|
36
51
|
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
|
|
52
|
+
- f350e90: Added a priority system for the sync messages
|
|
53
|
+
- Updated dependencies [35bbcd9]
|
|
54
|
+
- Updated dependencies [f350e90]
|
|
55
|
+
- cojson@0.7.35
|
|
41
56
|
|
|
42
57
|
## 0.7.34
|
|
43
58
|
|
|
44
59
|
### Patch Changes
|
|
45
60
|
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
|
|
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
|
|
53
68
|
|
|
54
69
|
## 0.7.34-neverthrow.8
|
|
55
70
|
|
|
56
71
|
### Patch Changes
|
|
57
72
|
|
|
58
|
-
-
|
|
59
|
-
|
|
73
|
+
- Updated dependencies
|
|
74
|
+
- cojson@0.7.34-neverthrow.8
|
|
60
75
|
|
|
61
76
|
## 0.7.34-neverthrow.7
|
|
62
77
|
|
|
63
78
|
### Patch Changes
|
|
64
79
|
|
|
65
|
-
-
|
|
66
|
-
|
|
80
|
+
- Updated dependencies
|
|
81
|
+
- cojson@0.7.34-neverthrow.7
|
|
67
82
|
|
|
68
83
|
## 0.7.34-neverthrow.4
|
|
69
84
|
|
|
70
85
|
### Patch Changes
|
|
71
86
|
|
|
72
|
-
-
|
|
73
|
-
|
|
87
|
+
- Updated dependencies
|
|
88
|
+
- cojson@0.7.34-neverthrow.4
|
|
74
89
|
|
|
75
90
|
## 0.7.34-neverthrow.3
|
|
76
91
|
|
|
77
92
|
### Patch Changes
|
|
78
93
|
|
|
79
|
-
-
|
|
80
|
-
|
|
94
|
+
- Updated dependencies
|
|
95
|
+
- cojson@0.7.34-neverthrow.3
|
|
81
96
|
|
|
82
97
|
## 0.7.34-neverthrow.1
|
|
83
98
|
|
|
84
99
|
### Patch Changes
|
|
85
100
|
|
|
86
|
-
-
|
|
87
|
-
|
|
101
|
+
- Updated dependencies
|
|
102
|
+
- cojson@0.7.34-neverthrow.1
|
|
88
103
|
|
|
89
104
|
## 0.7.34-neverthrow.0
|
|
90
105
|
|
|
91
106
|
### Patch Changes
|
|
92
107
|
|
|
93
|
-
-
|
|
94
|
-
|
|
108
|
+
- Updated dependencies
|
|
109
|
+
- cojson@0.7.34-neverthrow.0
|
|
95
110
|
|
|
96
111
|
## 0.7.33
|
|
97
112
|
|
|
98
113
|
### Patch Changes
|
|
99
114
|
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
104
|
-
-
|
|
105
|
-
|
|
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
|
|
106
121
|
|
|
107
122
|
## 0.7.33-hotfixes.6
|
|
108
123
|
|
|
109
124
|
### Patch Changes
|
|
110
125
|
|
|
111
|
-
-
|
|
126
|
+
- Get rid of simulated errors
|
|
112
127
|
|
|
113
128
|
## 0.7.33-hotfixes.5
|
|
114
129
|
|
|
115
130
|
### Patch Changes
|
|
116
131
|
|
|
117
|
-
-
|
|
118
|
-
-
|
|
119
|
-
|
|
132
|
+
- Make simulated errors even more likely
|
|
133
|
+
- Updated dependencies
|
|
134
|
+
- cojson@0.7.33-hotfixes.5
|
|
120
135
|
|
|
121
136
|
## 0.7.33-hotfixes.4
|
|
122
137
|
|
|
123
138
|
### Patch Changes
|
|
124
139
|
|
|
125
|
-
-
|
|
126
|
-
|
|
140
|
+
- Updated dependencies
|
|
141
|
+
- cojson@0.7.33-hotfixes.4
|
|
127
142
|
|
|
128
143
|
## 0.7.33-hotfixes.3
|
|
129
144
|
|
|
130
145
|
### Patch Changes
|
|
131
146
|
|
|
132
|
-
-
|
|
133
|
-
-
|
|
134
|
-
|
|
147
|
+
- Allow crashing whole node on peer errors
|
|
148
|
+
- Updated dependencies
|
|
149
|
+
- cojson@0.7.33-hotfixes.3
|
|
135
150
|
|
|
136
151
|
## 0.7.33-hotfixes.0
|
|
137
152
|
|
|
138
153
|
### Patch Changes
|
|
139
154
|
|
|
140
|
-
-
|
|
141
|
-
|
|
155
|
+
- Updated dependencies
|
|
156
|
+
- cojson@0.7.33-hotfixes.0
|
|
142
157
|
|
|
143
158
|
## 0.7.31
|
|
144
159
|
|
|
145
160
|
### Patch Changes
|
|
146
161
|
|
|
147
|
-
-
|
|
148
|
-
|
|
162
|
+
- Updated dependencies
|
|
163
|
+
- cojson@0.7.31
|
|
149
164
|
|
|
150
165
|
## 0.7.29
|
|
151
166
|
|
|
152
167
|
### Patch Changes
|
|
153
168
|
|
|
154
|
-
-
|
|
155
|
-
|
|
169
|
+
- Updated dependencies
|
|
170
|
+
- cojson@0.7.29
|
|
156
171
|
|
|
157
172
|
## 0.7.28
|
|
158
173
|
|
|
159
174
|
### Patch Changes
|
|
160
175
|
|
|
161
|
-
-
|
|
162
|
-
|
|
176
|
+
- Updated dependencies
|
|
177
|
+
- cojson@0.7.28
|
|
163
178
|
|
|
164
179
|
## 0.7.26
|
|
165
180
|
|
|
166
181
|
### Patch Changes
|
|
167
182
|
|
|
168
|
-
-
|
|
169
|
-
-
|
|
170
|
-
|
|
183
|
+
- Remove Effect from jazz/cojson internals
|
|
184
|
+
- Updated dependencies
|
|
185
|
+
- cojson@0.7.26
|
|
171
186
|
|
|
172
187
|
## 0.7.23
|
|
173
188
|
|
|
174
189
|
### Patch Changes
|
|
175
190
|
|
|
176
|
-
-
|
|
177
|
-
|
|
191
|
+
- Updated dependencies
|
|
192
|
+
- cojson@0.7.23
|
|
178
193
|
|
|
179
194
|
## 0.7.18
|
|
180
195
|
|
|
181
196
|
### Patch Changes
|
|
182
197
|
|
|
183
|
-
-
|
|
184
|
-
|
|
198
|
+
- Updated dependencies
|
|
199
|
+
- cojson@0.7.18
|
|
185
200
|
|
|
186
201
|
## 0.7.17
|
|
187
202
|
|
|
188
203
|
### Patch Changes
|
|
189
204
|
|
|
190
|
-
-
|
|
191
|
-
|
|
205
|
+
- Updated dependencies
|
|
206
|
+
- cojson@0.7.17
|
|
192
207
|
|
|
193
208
|
## 0.7.14
|
|
194
209
|
|
|
195
210
|
### Patch Changes
|
|
196
211
|
|
|
197
|
-
-
|
|
198
|
-
|
|
212
|
+
- Updated dependencies
|
|
213
|
+
- cojson@0.7.14
|
|
199
214
|
|
|
200
215
|
## 0.7.11
|
|
201
216
|
|
|
202
217
|
### Patch Changes
|
|
203
218
|
|
|
204
|
-
-
|
|
205
|
-
|
|
219
|
+
- Updated dependencies
|
|
220
|
+
- cojson@0.7.11
|
|
206
221
|
|
|
207
222
|
## 0.7.10
|
|
208
223
|
|
|
209
224
|
### Patch Changes
|
|
210
225
|
|
|
211
|
-
-
|
|
212
|
-
|
|
226
|
+
- Updated dependencies
|
|
227
|
+
- cojson@0.7.10
|
|
213
228
|
|
|
214
229
|
## 0.7.9
|
|
215
230
|
|
|
216
231
|
### Patch Changes
|
|
217
232
|
|
|
218
|
-
-
|
|
219
|
-
|
|
233
|
+
- Updated dependencies
|
|
234
|
+
- cojson@0.7.9
|
|
220
235
|
|
|
221
236
|
## 0.7.0
|
|
222
237
|
|
|
223
238
|
### Patch Changes
|
|
224
239
|
|
|
225
|
-
-
|
|
226
|
-
-
|
|
227
|
-
-
|
|
228
|
-
-
|
|
229
|
-
-
|
|
230
|
-
-
|
|
231
|
-
-
|
|
232
|
-
-
|
|
233
|
-
-
|
|
234
|
-
-
|
|
235
|
-
-
|
|
236
|
-
-
|
|
237
|
-
-
|
|
238
|
-
-
|
|
239
|
-
-
|
|
240
|
-
-
|
|
241
|
-
-
|
|
242
|
-
-
|
|
243
|
-
-
|
|
244
|
-
-
|
|
245
|
-
-
|
|
246
|
-
|
|
240
|
+
- c4151fc: Support stricter TS lint rules
|
|
241
|
+
- 21771c4: Reintroduce changes from main
|
|
242
|
+
- 69ac514: Use effect schema much less
|
|
243
|
+
- f0f6f1b: Clean up API more & re-add jazz-nodejs
|
|
244
|
+
- Updated dependencies [1a35307]
|
|
245
|
+
- Updated dependencies [96c494f]
|
|
246
|
+
- Updated dependencies [19f52b7]
|
|
247
|
+
- Updated dependencies [d8fe2b1]
|
|
248
|
+
- Updated dependencies [1200aae]
|
|
249
|
+
- Updated dependencies [52675c9]
|
|
250
|
+
- Updated dependencies [1a35307]
|
|
251
|
+
- Updated dependencies [e299c3e]
|
|
252
|
+
- Updated dependencies [bf0f8ec]
|
|
253
|
+
- Updated dependencies [c4151fc]
|
|
254
|
+
- Updated dependencies [8636319]
|
|
255
|
+
- Updated dependencies [952982e]
|
|
256
|
+
- Updated dependencies [21771c4]
|
|
257
|
+
- Updated dependencies [69ac514]
|
|
258
|
+
- Updated dependencies [f0f6f1b]
|
|
259
|
+
- Updated dependencies [1a44f87]
|
|
260
|
+
- Updated dependencies [63374cc]
|
|
261
|
+
- cojson@0.7.0
|
|
247
262
|
|
|
248
263
|
## 0.7.0-alpha.42
|
|
249
264
|
|
|
250
265
|
### Patch Changes
|
|
251
266
|
|
|
252
|
-
-
|
|
253
|
-
|
|
267
|
+
- Updated dependencies
|
|
268
|
+
- cojson@0.7.0-alpha.42
|
|
254
269
|
|
|
255
270
|
## 0.7.0-alpha.39
|
|
256
271
|
|
|
257
272
|
### Patch Changes
|
|
258
273
|
|
|
259
|
-
-
|
|
260
|
-
|
|
274
|
+
- Updated dependencies
|
|
275
|
+
- cojson@0.7.0-alpha.39
|
|
261
276
|
|
|
262
277
|
## 0.7.0-alpha.38
|
|
263
278
|
|
|
264
279
|
### Patch Changes
|
|
265
280
|
|
|
266
|
-
-
|
|
267
|
-
|
|
281
|
+
- Updated dependencies
|
|
282
|
+
- cojson@0.7.0-alpha.38
|
|
268
283
|
|
|
269
284
|
## 0.7.0-alpha.37
|
|
270
285
|
|
|
271
286
|
### Patch Changes
|
|
272
287
|
|
|
273
|
-
-
|
|
274
|
-
|
|
288
|
+
- Updated dependencies
|
|
289
|
+
- cojson@0.7.0-alpha.37
|
|
275
290
|
|
|
276
291
|
## 0.7.0-alpha.36
|
|
277
292
|
|
|
278
293
|
### Patch Changes
|
|
279
294
|
|
|
280
|
-
-
|
|
281
|
-
-
|
|
282
|
-
|
|
295
|
+
- Updated dependencies [1a35307]
|
|
296
|
+
- Updated dependencies [1a35307]
|
|
297
|
+
- cojson@0.7.0-alpha.36
|
|
283
298
|
|
|
284
299
|
## 0.7.0-alpha.35
|
|
285
300
|
|
|
286
301
|
### Patch Changes
|
|
287
302
|
|
|
288
|
-
-
|
|
289
|
-
|
|
303
|
+
- Updated dependencies
|
|
304
|
+
- cojson@0.7.0-alpha.35
|
|
290
305
|
|
|
291
306
|
## 0.7.0-alpha.29
|
|
292
307
|
|
|
293
308
|
### Patch Changes
|
|
294
309
|
|
|
295
|
-
-
|
|
296
|
-
-
|
|
297
|
-
|
|
310
|
+
- Reintroduce changes from main
|
|
311
|
+
- Updated dependencies
|
|
312
|
+
- cojson@0.7.0-alpha.29
|
|
298
313
|
|
|
299
314
|
## 0.7.0-alpha.28
|
|
300
315
|
|
|
301
316
|
### Patch Changes
|
|
302
317
|
|
|
303
|
-
-
|
|
304
|
-
|
|
318
|
+
- Updated dependencies
|
|
319
|
+
- cojson@0.7.0-alpha.28
|
|
305
320
|
|
|
306
321
|
## 0.7.0-alpha.27
|
|
307
322
|
|
|
308
323
|
### Patch Changes
|
|
309
324
|
|
|
310
|
-
-
|
|
311
|
-
|
|
325
|
+
- Updated dependencies
|
|
326
|
+
- cojson@0.7.0-alpha.27
|
|
312
327
|
|
|
313
328
|
## 0.7.0-alpha.24
|
|
314
329
|
|
|
315
330
|
### Patch Changes
|
|
316
331
|
|
|
317
|
-
-
|
|
318
|
-
|
|
332
|
+
- Updated dependencies
|
|
333
|
+
- cojson@0.7.0-alpha.24
|
|
319
334
|
|
|
320
335
|
## 0.7.0-alpha.11
|
|
321
336
|
|
|
322
337
|
### Patch Changes
|
|
323
338
|
|
|
324
|
-
-
|
|
325
|
-
-
|
|
326
|
-
|
|
339
|
+
- Support stricter TS lint rules
|
|
340
|
+
- Updated dependencies
|
|
341
|
+
- cojson@0.7.0-alpha.11
|
|
327
342
|
|
|
328
343
|
## 0.7.0-alpha.10
|
|
329
344
|
|
|
330
345
|
### Patch Changes
|
|
331
346
|
|
|
332
|
-
-
|
|
333
|
-
-
|
|
334
|
-
|
|
347
|
+
- Clean up API more & re-add jazz-nodejs
|
|
348
|
+
- Updated dependencies
|
|
349
|
+
- cojson@0.7.0-alpha.10
|
|
335
350
|
|
|
336
351
|
## 0.5.3-alpha.1
|
|
337
352
|
|
|
338
353
|
### Patch Changes
|
|
339
354
|
|
|
340
|
-
-
|
|
341
|
-
-
|
|
342
|
-
|
|
355
|
+
- Use effect schema much less
|
|
356
|
+
- Updated dependencies
|
|
357
|
+
- cojson@0.7.0-alpha.1
|
|
343
358
|
|
|
344
359
|
## 0.5.3-alpha.0
|
|
345
360
|
|
|
346
361
|
### Patch Changes
|
|
347
362
|
|
|
348
|
-
-
|
|
349
|
-
|
|
363
|
+
- Updated dependencies
|
|
364
|
+
- cojson@0.7.0-alpha.0
|
|
350
365
|
|
|
351
366
|
## 0.5.2
|
|
352
367
|
|
|
353
368
|
### Patch Changes
|
|
354
369
|
|
|
355
|
-
-
|
|
356
|
-
|
|
370
|
+
- Updated dependencies
|
|
371
|
+
- cojson@0.6.0
|
|
357
372
|
|
|
358
373
|
## 0.5.1
|
|
359
374
|
|
|
360
375
|
### Patch Changes
|
|
361
376
|
|
|
362
|
-
-
|
|
377
|
+
- Make typedefs for better-sqlite3 a normal dependency
|
|
363
378
|
|
|
364
379
|
## 0.5.0
|
|
365
380
|
|
|
366
381
|
### Minor Changes
|
|
367
382
|
|
|
368
|
-
-
|
|
383
|
+
- 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.
|
|
369
384
|
|
|
370
385
|
### Patch Changes
|
|
371
386
|
|
|
372
|
-
-
|
|
373
|
-
|
|
387
|
+
- Updated dependencies
|
|
388
|
+
- 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) {
|
|
@@ -22,7 +22,7 @@ export class SQLiteStorage {
|
|
|
22
22
|
processMessages().catch((e) => console.error("Error in processMessages in sqlite", e));
|
|
23
23
|
}
|
|
24
24
|
static async asPeer({ filename, trace, localNodeName = "local", }) {
|
|
25
|
-
const [localNodeAsPeer, storageAsPeer] = cojsonInternals.connectedPeers(localNodeName, "storage", { peer1role: "client", peer2role: "
|
|
25
|
+
const [localNodeAsPeer, storageAsPeer] = cojsonInternals.connectedPeers(localNodeName, "storage", { peer1role: "client", peer2role: "storage", trace, crashOnClose: true });
|
|
26
26
|
await SQLiteStorage.open(filename, localNodeAsPeer.incoming, localNodeAsPeer.outgoing);
|
|
27
27
|
return { ...storageAsPeer, priority: 100 };
|
|
28
28
|
}
|
|
@@ -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;
|