@dxos/echo-db 2.33.5-dev.c37556a4 → 2.33.5-dev.ebc105f7
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/dist/src/parties/party-factory.js +2 -2
- package/dist/src/parties/party-factory.js.map +1 -1
- package/dist/src/parties/party-manager.test.js +6 -3
- package/dist/src/parties/party-manager.test.js.map +1 -1
- package/dist/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/src/pipeline/message-selector.js +6 -5
- package/dist/src/pipeline/message-selector.js.map +1 -1
- package/dist/src/pipeline/party-core.test.js +13 -12
- package/dist/src/pipeline/party-core.test.js.map +1 -1
- package/dist/src/pipeline/pipeline.d.ts.map +1 -1
- package/dist/src/pipeline/pipeline.js +8 -8
- package/dist/src/pipeline/pipeline.js.map +1 -1
- package/dist/src/pipeline/pipeline.test.js +1 -2
- package/dist/src/pipeline/pipeline.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/src/parties/party-factory.ts +2 -2
- package/src/parties/party-manager.test.ts +11 -4
- package/src/pipeline/message-selector.ts +6 -5
- package/src/pipeline/party-core.test.ts +14 -13
- package/src/pipeline/pipeline.test.ts +1 -2
- package/src/pipeline/pipeline.ts +9 -8
|
@@ -26,27 +26,28 @@ const log = debug('dxos:echo-db:message-selector');
|
|
|
26
26
|
export const createMessageSelector = (partyProcessor: PartyStateProvider, timeframeClock: TimeframeClock): MessageSelector => candidates => {
|
|
27
27
|
// Check ECHO message candidates first since they are less expensive than HALO cancidates.
|
|
28
28
|
for (let i = 0; i < candidates.length; i++) {
|
|
29
|
-
const { data: { echo } } = candidates[i];
|
|
29
|
+
const { data: { timeframe, echo } } = candidates[i];
|
|
30
30
|
const feedKey = PublicKey.from(candidates[i].key);
|
|
31
31
|
if (!echo) {
|
|
32
32
|
continue;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
assert(
|
|
36
|
-
if (partyProcessor.isFeedAdmitted(feedKey) && !timeframeClock.hasGaps(
|
|
35
|
+
assert(timeframe);
|
|
36
|
+
if (partyProcessor.isFeedAdmitted(feedKey) && !timeframeClock.hasGaps(timeframe)) {
|
|
37
37
|
return i;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// Check HALO message candidates.
|
|
42
42
|
for (let i = 0; i < candidates.length; i++) {
|
|
43
|
-
const { data: { halo } } = candidates[i];
|
|
43
|
+
const { data: { timeframe, halo } } = candidates[i];
|
|
44
44
|
const feedKey = PublicKey.from(candidates[i].key);
|
|
45
45
|
if (!halo) {
|
|
46
46
|
continue;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
assert(timeframe);
|
|
50
|
+
if (partyProcessor.isFeedAdmitted(feedKey) && !timeframeClock.hasGaps(timeframe)) {
|
|
50
51
|
return i;
|
|
51
52
|
}
|
|
52
53
|
|
|
@@ -8,7 +8,8 @@ import { it as test } from 'mocha';
|
|
|
8
8
|
import { promiseTimeout } from '@dxos/async';
|
|
9
9
|
import { createFeedAdmitMessage, createPartyGenesisMessage, Keyring, KeyType } from '@dxos/credentials';
|
|
10
10
|
import { createId, PublicKey } from '@dxos/crypto';
|
|
11
|
-
import {
|
|
11
|
+
import { checkType } from '@dxos/debug';
|
|
12
|
+
import { codec, FeedMessage, Timeframe } from '@dxos/echo-protocol';
|
|
12
13
|
import { FeedStore } from '@dxos/feed-store';
|
|
13
14
|
import { createTestProtocolPair } from '@dxos/mesh-protocol';
|
|
14
15
|
import { ModelFactory } from '@dxos/model-factory';
|
|
@@ -175,16 +176,16 @@ describe('PartyCore', () => {
|
|
|
175
176
|
const feed = await partyFeedProvider.createOrOpenWritableFeed();
|
|
176
177
|
|
|
177
178
|
const itemId = createId();
|
|
178
|
-
await feed.feed.append({
|
|
179
|
+
await feed.feed.append(checkType<FeedMessage>({
|
|
180
|
+
timeframe: new Timeframe(),
|
|
179
181
|
echo: {
|
|
180
182
|
itemId,
|
|
181
183
|
genesis: {
|
|
182
184
|
itemType: 'dxos:example',
|
|
183
185
|
modelType: ObjectModel.meta.type
|
|
184
|
-
}
|
|
185
|
-
timeframe: new Timeframe()
|
|
186
|
+
}
|
|
186
187
|
}
|
|
187
|
-
});
|
|
188
|
+
}));
|
|
188
189
|
|
|
189
190
|
await promiseTimeout(party.database.waitForItem({ id: itemId }), 1000, new Error('timeout'));
|
|
190
191
|
});
|
|
@@ -205,16 +206,16 @@ describe('PartyCore', () => {
|
|
|
205
206
|
));
|
|
206
207
|
|
|
207
208
|
const itemId = createId();
|
|
208
|
-
await feed2.append({
|
|
209
|
+
await feed2.append(checkType<FeedMessage>({
|
|
210
|
+
timeframe: new Timeframe(),
|
|
209
211
|
echo: {
|
|
210
212
|
itemId,
|
|
211
213
|
genesis: {
|
|
212
214
|
itemType: 'dxos:example',
|
|
213
215
|
modelType: ObjectModel.meta.type
|
|
214
|
-
}
|
|
215
|
-
timeframe: new Timeframe()
|
|
216
|
+
}
|
|
216
217
|
}
|
|
217
|
-
});
|
|
218
|
+
}));
|
|
218
219
|
|
|
219
220
|
await promiseTimeout(party.database.waitForItem({ id: itemId }), 1000, new Error('timeout'));
|
|
220
221
|
});
|
|
@@ -235,16 +236,16 @@ describe('PartyCore', () => {
|
|
|
235
236
|
|
|
236
237
|
const feed2 = await feedStore.openReadWriteFeed(fullKey!.publicKey, fullKey!.secretKey!);
|
|
237
238
|
const itemId = createId();
|
|
238
|
-
await feed2.append({
|
|
239
|
+
await feed2.append(checkType<FeedMessage>({
|
|
240
|
+
timeframe: new Timeframe(),
|
|
239
241
|
echo: {
|
|
240
242
|
itemId,
|
|
241
243
|
genesis: {
|
|
242
244
|
itemType: 'dxos:example',
|
|
243
245
|
modelType: ObjectModel.meta.type
|
|
244
|
-
}
|
|
245
|
-
timeframe: new Timeframe()
|
|
246
|
+
}
|
|
246
247
|
}
|
|
247
|
-
});
|
|
248
|
+
}));
|
|
248
249
|
|
|
249
250
|
await promiseTimeout(party.database.waitForItem({ id: itemId }), 1000, new Error('timeout'));
|
|
250
251
|
});
|
package/src/pipeline/pipeline.ts
CHANGED
|
@@ -109,6 +109,8 @@ export class Pipeline {
|
|
|
109
109
|
try {
|
|
110
110
|
const { data: message } = block;
|
|
111
111
|
|
|
112
|
+
this._timeframeClock.updateTimeframe(PublicKey.from(block.key), block.seq);
|
|
113
|
+
|
|
112
114
|
//
|
|
113
115
|
// HALO
|
|
114
116
|
//
|
|
@@ -125,7 +127,6 @@ export class Pipeline {
|
|
|
125
127
|
//
|
|
126
128
|
|
|
127
129
|
if (message.echo) {
|
|
128
|
-
this._timeframeClock.updateTimeframe(PublicKey.from(block.key), block.seq);
|
|
129
130
|
const memberKey = this._partyProcessor.getFeedOwningMember(PublicKey.from(block.key));
|
|
130
131
|
assert(memberKey, `Ownership of feed ${keyToString(block.key)} could not be determined.`);
|
|
131
132
|
|
|
@@ -138,7 +139,7 @@ export class Pipeline {
|
|
|
138
139
|
seq: block.seq,
|
|
139
140
|
feedKey: block.key,
|
|
140
141
|
memberKey,
|
|
141
|
-
timeframe: message.
|
|
142
|
+
timeframe: message.timeframe ?? new Timeframe()
|
|
142
143
|
},
|
|
143
144
|
data: message.echo
|
|
144
145
|
}));
|
|
@@ -167,13 +168,13 @@ export class Pipeline {
|
|
|
167
168
|
}, this._feedWriter);
|
|
168
169
|
|
|
169
170
|
this._outboundEchoStream = mapFeedWriter<EchoEnvelope, FeedMessage>(async message => ({
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
timeframe: this._timeframeClock.timeframe,
|
|
172
|
+
echo: message
|
|
173
|
+
}), loggingWriter);
|
|
174
|
+
this._outboundHaloStream = mapFeedWriter<HaloMessage, FeedMessage>(async message => ({
|
|
175
|
+
timeframe: this._timeframeClock.timeframe,
|
|
176
|
+
halo: message
|
|
174
177
|
}), loggingWriter);
|
|
175
|
-
this._outboundHaloStream =
|
|
176
|
-
mapFeedWriter<HaloMessage, FeedMessage>(async message => ({ halo: message }), loggingWriter);
|
|
177
178
|
}
|
|
178
179
|
|
|
179
180
|
return [
|