@kumiai/hub-server 0.10.1 → 0.10.2
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/lib/handlers.js +2 -1
- package/lib/memoryStore.js +12 -3
- package/package.json +7 -7
package/lib/handlers.js
CHANGED
package/lib/memoryStore.js
CHANGED
|
@@ -54,6 +54,7 @@ function isLive(entry, nowSeconds) {
|
|
|
54
54
|
const entries = new Map();
|
|
55
55
|
const topicLogs = new Map();
|
|
56
56
|
const heads = new Map();
|
|
57
|
+
const removedThrough = new Map();
|
|
57
58
|
const deliveries = new Map();
|
|
58
59
|
/**
|
|
59
60
|
* publishID -> the sequenceID it was accepted as. Not a log entry and not reachable from one: no
|
|
@@ -87,6 +88,10 @@ function isLive(entry, nowSeconds) {
|
|
|
87
88
|
function removeEntry(sequenceID) {
|
|
88
89
|
const entry = entries.get(sequenceID);
|
|
89
90
|
if (entry == null) return;
|
|
91
|
+
if (entry.retain === 'log') {
|
|
92
|
+
const removed = removedThrough.get(entry.topicID);
|
|
93
|
+
if (removed == null || sequenceID > removed) removedThrough.set(entry.topicID, sequenceID);
|
|
94
|
+
}
|
|
90
95
|
for (const recipientDID of entry.pendingFor){
|
|
91
96
|
const list = deliveries.get(recipientDID);
|
|
92
97
|
if (list != null) {
|
|
@@ -295,7 +300,8 @@ function isLive(entry, nowSeconds) {
|
|
|
295
300
|
return {
|
|
296
301
|
messages,
|
|
297
302
|
head: heads.get(params.topicID) ?? null,
|
|
298
|
-
oldest: log[0] ?? null
|
|
303
|
+
oldest: log[0] ?? null,
|
|
304
|
+
gap: removedThrough.has(params.topicID) && (after == null || removedThrough.get(params.topicID) > after)
|
|
299
305
|
};
|
|
300
306
|
},
|
|
301
307
|
async trim (params) {
|
|
@@ -318,14 +324,17 @@ function isLive(entry, nowSeconds) {
|
|
|
318
324
|
}
|
|
319
325
|
},
|
|
320
326
|
async purge (params) {
|
|
321
|
-
// The age bound, for both classes: the same removal path, the same invariants — head is
|
|
322
|
-
// untouched.
|
|
323
327
|
const now = Date.now();
|
|
324
328
|
const purgedIDs = [];
|
|
329
|
+
const retainedTopics = new Set();
|
|
330
|
+
// Insertion order is log-position order, even if the clock moves backwards.
|
|
325
331
|
for (const [sequenceID, entry] of entries){
|
|
332
|
+
if (entry.retain === 'log' && retainedTopics.has(entry.topicID)) continue;
|
|
326
333
|
const retention = retentionOf(entry.topicID, params.olderThan);
|
|
327
334
|
if (entry.storedAt <= now - retention * 1000) {
|
|
328
335
|
purgedIDs.push(sequenceID);
|
|
336
|
+
} else if (entry.retain === 'log') {
|
|
337
|
+
retainedTopics.add(entry.topicID);
|
|
329
338
|
}
|
|
330
339
|
}
|
|
331
340
|
for (const sequenceID of purgedIDs){
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kumiai/hub-server",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "Hub server for Enkaku E2EE group message routing",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hub",
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"lib/*"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@enkaku/protocol": "^0.21.
|
|
28
|
+
"@enkaku/protocol": "^0.21.4",
|
|
29
29
|
"@enkaku/server": "^0.21.3",
|
|
30
30
|
"@kokuin/token": "^0.5.0",
|
|
31
|
-
"@kumiai/hub-protocol": "^0.10.
|
|
32
|
-
"@sozai/codec": "^0.4.
|
|
33
|
-
"@sozai/event": "^0.1.
|
|
34
|
-
"@sozai/log": "^0.
|
|
31
|
+
"@kumiai/hub-protocol": "^0.10.1",
|
|
32
|
+
"@sozai/codec": "^0.4.2",
|
|
33
|
+
"@sozai/event": "^0.1.5",
|
|
34
|
+
"@sozai/log": "^0.4.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@enkaku/client": "^0.21.3",
|
|
38
38
|
"@enkaku/transport": "^0.21.3",
|
|
39
|
-
"@kumiai/hub-conformance": "^0.10.
|
|
39
|
+
"@kumiai/hub-conformance": "^0.10.1",
|
|
40
40
|
"@kumiai/hub-wake": "^0.10.0"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|