@dxos/echo-db 2.33.0 → 2.33.1-dev.17ad8706
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/database/data-mirror.js +2 -2
- package/dist/src/database/data-mirror.js.map +1 -1
- package/dist/src/database/item-demuxer.test.js +2 -2
- package/dist/src/database/item-demuxer.test.js.map +1 -1
- package/dist/src/echo.test.js +70 -0
- package/dist/src/echo.test.js.map +1 -1
- package/dist/src/invitations/greeting-initiator.d.ts +1 -4
- package/dist/src/invitations/greeting-initiator.d.ts.map +1 -1
- package/dist/src/invitations/greeting-initiator.js +1 -7
- package/dist/src/invitations/greeting-initiator.js.map +1 -1
- package/dist/src/invitations/halo-recovery-initiator.d.ts.map +1 -1
- package/dist/src/invitations/halo-recovery-initiator.js +2 -2
- package/dist/src/invitations/halo-recovery-initiator.js.map +1 -1
- package/dist/src/invitations/offline-invitation-claimer.d.ts.map +1 -1
- package/dist/src/invitations/offline-invitation-claimer.js +2 -2
- package/dist/src/invitations/offline-invitation-claimer.js.map +1 -1
- package/dist/src/parties/authenticator.d.ts +5 -0
- package/dist/src/parties/authenticator.d.ts.map +1 -0
- package/dist/src/parties/authenticator.js +27 -0
- package/dist/src/parties/authenticator.js.map +1 -0
- package/dist/src/parties/party-core.d.ts.map +1 -1
- package/dist/src/parties/party-core.js +8 -3
- package/dist/src/parties/party-core.js.map +1 -1
- package/dist/src/parties/party-core.test.js +136 -5
- package/dist/src/parties/party-core.test.js.map +1 -1
- package/dist/src/parties/party-factory.d.ts.map +1 -1
- package/dist/src/parties/party-factory.js +1 -5
- package/dist/src/parties/party-factory.js.map +1 -1
- package/dist/src/parties/party-internal.d.ts.map +1 -1
- package/dist/src/parties/party-internal.js +6 -4
- package/dist/src/parties/party-internal.js.map +1 -1
- package/dist/src/parties/party-manager.test.js +4 -4
- package/dist/src/parties/party-manager.test.js.map +1 -1
- package/dist/src/pipeline/party-feed-provider.d.ts +5 -1
- package/dist/src/pipeline/party-feed-provider.d.ts.map +1 -1
- package/dist/src/pipeline/party-feed-provider.js +36 -13
- package/dist/src/pipeline/party-feed-provider.js.map +1 -1
- package/dist/src/pipeline/party-processor.d.ts +3 -4
- package/dist/src/pipeline/party-processor.d.ts.map +1 -1
- package/dist/src/pipeline/party-processor.js +8 -14
- package/dist/src/pipeline/party-processor.js.map +1 -1
- package/dist/src/pipeline/party-processor.test.js +8 -8
- package/dist/src/pipeline/party-processor.test.js.map +1 -1
- package/dist/src/pipeline/party-protocol-factory.d.ts +11 -0
- package/dist/src/pipeline/party-protocol-factory.d.ts.map +1 -1
- package/dist/src/pipeline/party-protocol-factory.js +2 -1
- package/dist/src/pipeline/party-protocol-factory.js.map +1 -1
- package/dist/src/pipeline/pipeline.js +1 -1
- package/dist/src/pipeline/pipeline.js.map +1 -1
- package/dist/src/pipeline/pipeline.test.js +3 -3
- package/dist/src/pipeline/pipeline.test.js.map +1 -1
- package/dist/src/util/persistant-ram-storage.d.ts.map +1 -1
- package/dist/src/util/persistant-ram-storage.js +1 -1
- package/dist/src/util/persistant-ram-storage.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/src/database/data-mirror.ts +2 -2
- package/src/database/item-demuxer.test.ts +3 -3
- package/src/echo.test.ts +100 -1
- package/src/invitations/greeting-initiator.ts +1 -26
- package/src/invitations/halo-recovery-initiator.ts +4 -4
- package/src/invitations/offline-invitation-claimer.ts +4 -4
- package/src/parties/authenticator.ts +31 -0
- package/src/parties/party-core.test.ts +233 -10
- package/src/parties/party-core.ts +9 -3
- package/src/parties/party-factory.ts +1 -6
- package/src/parties/party-internal.ts +15 -6
- package/src/parties/party-manager.test.ts +5 -5
- package/src/pipeline/party-feed-provider.ts +40 -14
- package/src/pipeline/party-processor.test.ts +8 -8
- package/src/pipeline/party-processor.ts +8 -18
- package/src/pipeline/party-protocol-factory.ts +1 -1
- package/src/pipeline/pipeline.test.ts +4 -4
- package/src/pipeline/pipeline.ts +1 -1
- package/src/util/persistant-ram-storage.ts +3 -3
|
@@ -29,7 +29,7 @@ import { createWritableFeedStream, FeedStore } from '@dxos/feed-store';
|
|
|
29
29
|
import { ModelFactory } from '@dxos/model-factory';
|
|
30
30
|
import { NetworkManager } from '@dxos/network-manager';
|
|
31
31
|
import { ObjectModel } from '@dxos/object-model';
|
|
32
|
-
import { createStorage,
|
|
32
|
+
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
33
33
|
import { afterTest } from '@dxos/testutils';
|
|
34
34
|
|
|
35
35
|
import { Item } from '../api';
|
|
@@ -58,7 +58,7 @@ const log = debug('dxos:echo:parties:party-manager:test');
|
|
|
58
58
|
const setup = async (open = true, createIdentity = true) => {
|
|
59
59
|
const keyring = new Keyring();
|
|
60
60
|
const metadataStore = new MetadataStore(createRamStorage());
|
|
61
|
-
const feedStore = new FeedStore(createStorage('',
|
|
61
|
+
const feedStore = new FeedStore(createStorage('', StorageType.RAM), { valueEncoding: codec });
|
|
62
62
|
|
|
63
63
|
let seedPhrase;
|
|
64
64
|
if (createIdentity) {
|
|
@@ -73,7 +73,7 @@ const setup = async (open = true, createIdentity = true) => {
|
|
|
73
73
|
assert(keyring.keys.length === 1);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
const snapshotStore = new SnapshotStore(createStorage('',
|
|
76
|
+
const snapshotStore = new SnapshotStore(createStorage('', StorageType.RAM));
|
|
77
77
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
78
78
|
const networkManager = new NetworkManager();
|
|
79
79
|
const feedProviderFactory = (partyKey: PublicKey) => new PartyFeedProvider(metadataStore, keyring, feedStore, partyKey);
|
|
@@ -179,7 +179,7 @@ describe('Party manager', () => {
|
|
|
179
179
|
});
|
|
180
180
|
|
|
181
181
|
test('Create from cold start', async () => {
|
|
182
|
-
const storage = createStorage('',
|
|
182
|
+
const storage = createStorage('', StorageType.RAM);
|
|
183
183
|
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
184
184
|
|
|
185
185
|
const keyring = new Keyring();
|
|
@@ -189,7 +189,7 @@ describe('Party manager', () => {
|
|
|
189
189
|
await keyring.createKeyRecord({ type: KeyType.DEVICE });
|
|
190
190
|
|
|
191
191
|
const modelFactory = new ModelFactory().registerModel(ObjectModel);
|
|
192
|
-
const snapshotStore = new SnapshotStore(createStorage('',
|
|
192
|
+
const snapshotStore = new SnapshotStore(createStorage('', StorageType.RAM));
|
|
193
193
|
const networkManager = new NetworkManager();
|
|
194
194
|
const feedProviderFactory = (partyKey: PublicKey) => new PartyFeedProvider(metadataStore, keyring, feedStore, partyKey);
|
|
195
195
|
const partyFactory: PartyFactory = new PartyFactory(() => identityManager.identity, networkManager, modelFactory, snapshotStore, feedProviderFactory);
|
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
import assert from 'assert';
|
|
6
6
|
import debug from 'debug';
|
|
7
7
|
|
|
8
|
+
import { Event } from '@dxos/async';
|
|
8
9
|
import { Keyring, KeyType } from '@dxos/credentials';
|
|
9
10
|
import { PublicKey } from '@dxos/crypto';
|
|
10
11
|
import { FeedStoreIterator, MessageSelector, Timeframe } from '@dxos/echo-protocol';
|
|
11
12
|
import { FeedDescriptor, FeedStore } from '@dxos/feed-store';
|
|
13
|
+
import { ComplexMap } from '@dxos/util';
|
|
12
14
|
|
|
13
15
|
import { MetadataStore } from '../metadata';
|
|
14
16
|
|
|
@@ -16,6 +18,9 @@ const STALL_TIMEOUT = 1000;
|
|
|
16
18
|
const warn = debug('dxos:echo-db:party-feed-provider:warn');
|
|
17
19
|
|
|
18
20
|
export class PartyFeedProvider {
|
|
21
|
+
private readonly _feeds = new ComplexMap<PublicKey, FeedDescriptor>(x => x.toHex())
|
|
22
|
+
readonly feedOpened = new Event<FeedDescriptor>();
|
|
23
|
+
|
|
19
24
|
constructor (
|
|
20
25
|
private readonly _metadataStore: MetadataStore,
|
|
21
26
|
private readonly _keyring: Keyring,
|
|
@@ -23,14 +28,13 @@ export class PartyFeedProvider {
|
|
|
23
28
|
private readonly _partyKey: PublicKey
|
|
24
29
|
) {}
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
getFeeds (): FeedDescriptor[] {
|
|
32
|
+
return Array.from(this._feeds.values());
|
|
33
|
+
}
|
|
34
|
+
|
|
27
35
|
async createOrOpenWritableFeed () {
|
|
28
36
|
const partyMetadata = this._metadataStore.getParty(this._partyKey);
|
|
29
|
-
if (!partyMetadata) {
|
|
30
|
-
return this._createReadWriteFeed();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (!partyMetadata.dataFeedKey) {
|
|
37
|
+
if (!partyMetadata?.dataFeedKey) {
|
|
34
38
|
return this._createReadWriteFeed();
|
|
35
39
|
}
|
|
36
40
|
|
|
@@ -39,22 +43,42 @@ export class PartyFeedProvider {
|
|
|
39
43
|
return this._createReadWriteFeed();
|
|
40
44
|
}
|
|
41
45
|
|
|
46
|
+
if (this._feeds.has(fullKey.publicKey)) {
|
|
47
|
+
return this._feeds.get(fullKey.publicKey)!;
|
|
48
|
+
}
|
|
49
|
+
|
|
42
50
|
const feed = await this._feedStore.openReadWriteFeed(fullKey.publicKey, fullKey.secretKey);
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
this._feeds.set(fullKey.publicKey, feed);
|
|
52
|
+
this.feedOpened.emit(feed);
|
|
45
53
|
return feed;
|
|
46
54
|
}
|
|
47
55
|
|
|
48
|
-
|
|
49
|
-
|
|
56
|
+
async openKnownFeeds () {
|
|
57
|
+
for (const feedKey of this._metadataStore.getParty(this._partyKey)?.feedKeys ?? []) {
|
|
58
|
+
if (!this._feeds.has(feedKey)) {
|
|
59
|
+
const fullKey = this._keyring.getFullKey(feedKey);
|
|
60
|
+
const feed = fullKey?.secretKey
|
|
61
|
+
? await this._feedStore.openReadWriteFeed(fullKey.publicKey, fullKey.secretKey)
|
|
62
|
+
: await this._feedStore.openReadOnlyFeed(feedKey);
|
|
63
|
+
this._feeds.set(feedKey, feed);
|
|
64
|
+
this.feedOpened.emit(feed);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
50
67
|
}
|
|
51
68
|
|
|
52
69
|
async createOrOpenReadOnlyFeed (feedKey: PublicKey): Promise<FeedDescriptor> {
|
|
70
|
+
if (this._feeds.has(feedKey)) {
|
|
71
|
+
return this._feeds.get(feedKey)!;
|
|
72
|
+
}
|
|
73
|
+
|
|
53
74
|
await this._metadataStore.addPartyFeed(this._partyKey, feedKey);
|
|
54
75
|
if (!this._keyring.hasKey(feedKey)) {
|
|
55
76
|
await this._keyring.addPublicKey({ type: KeyType.FEED, publicKey: feedKey });
|
|
56
77
|
}
|
|
57
|
-
|
|
78
|
+
const feed = await this._feedStore.openReadOnlyFeed(feedKey);
|
|
79
|
+
this._feeds.set(feedKey, feed);
|
|
80
|
+
this.feedOpened.emit(feed);
|
|
81
|
+
return feed;
|
|
58
82
|
}
|
|
59
83
|
|
|
60
84
|
private async _createReadWriteFeed () {
|
|
@@ -63,16 +87,18 @@ export class PartyFeedProvider {
|
|
|
63
87
|
assert(fullKey && fullKey.secretKey);
|
|
64
88
|
await this._metadataStore.setDataFeed(this._partyKey, fullKey.publicKey);
|
|
65
89
|
const feed = await this._feedStore.openReadWriteFeed(fullKey.publicKey, fullKey.secretKey);
|
|
90
|
+
this._feeds.set(fullKey.publicKey, feed);
|
|
91
|
+
this.feedOpened.emit(feed);
|
|
66
92
|
return feed;
|
|
67
93
|
}
|
|
68
94
|
|
|
69
95
|
async createIterator (messageSelector: MessageSelector, initialTimeframe?: Timeframe) {
|
|
70
96
|
const iterator = new FeedStoreIterator(() => true, messageSelector, initialTimeframe ?? new Timeframe());
|
|
71
|
-
for (const
|
|
72
|
-
iterator.addFeedDescriptor(
|
|
97
|
+
for (const feed of this._feeds.values()) {
|
|
98
|
+
iterator.addFeedDescriptor(feed);
|
|
73
99
|
}
|
|
74
100
|
|
|
75
|
-
this.
|
|
101
|
+
this.feedOpened.on((descriptor) => {
|
|
76
102
|
if (this._metadataStore.getParty(this._partyKey)?.feedKeys?.find(feedKey => feedKey.equals(descriptor.key))) {
|
|
77
103
|
iterator.addFeedDescriptor(descriptor);
|
|
78
104
|
}
|
|
@@ -36,7 +36,7 @@ describe('party-processor', () => {
|
|
|
36
36
|
|
|
37
37
|
const message: IHaloStream = {
|
|
38
38
|
meta: {
|
|
39
|
-
feedKey: feedKey.publicKey
|
|
39
|
+
feedKey: feedKey.publicKey,
|
|
40
40
|
seq: 0
|
|
41
41
|
// TODO(telackey): Should ownership data go here?
|
|
42
42
|
},
|
|
@@ -67,7 +67,7 @@ describe('party-processor', () => {
|
|
|
67
67
|
|
|
68
68
|
const genesisMessage: IHaloStream = {
|
|
69
69
|
meta: {
|
|
70
|
-
feedKey: feedKey.publicKey
|
|
70
|
+
feedKey: feedKey.publicKey,
|
|
71
71
|
seq: 0
|
|
72
72
|
// TODO(telackey): Should ownership data go here?
|
|
73
73
|
},
|
|
@@ -78,7 +78,7 @@ describe('party-processor', () => {
|
|
|
78
78
|
const feedKey2 = await keyring.createKeyRecord({ type: KeyType.FEED });
|
|
79
79
|
const feedAdmit: IHaloStream = {
|
|
80
80
|
meta: {
|
|
81
|
-
feedKey: feedKey.publicKey
|
|
81
|
+
feedKey: feedKey.publicKey,
|
|
82
82
|
seq: 0
|
|
83
83
|
// TODO(telackey): Should ownership data go here?
|
|
84
84
|
},
|
|
@@ -106,7 +106,7 @@ describe('party-processor', () => {
|
|
|
106
106
|
|
|
107
107
|
const genesisMessage: IHaloStream = {
|
|
108
108
|
meta: {
|
|
109
|
-
feedKey: feedKey.publicKey
|
|
109
|
+
feedKey: feedKey.publicKey,
|
|
110
110
|
seq: 0
|
|
111
111
|
// TODO(telackey): Should ownership data go here?
|
|
112
112
|
},
|
|
@@ -115,7 +115,7 @@ describe('party-processor', () => {
|
|
|
115
115
|
await partyProcessor.processMessage(genesisMessage);
|
|
116
116
|
const feedAdmit: IHaloStream = {
|
|
117
117
|
meta: {
|
|
118
|
-
feedKey: feedKey.publicKey
|
|
118
|
+
feedKey: feedKey.publicKey,
|
|
119
119
|
seq: 0
|
|
120
120
|
// TODO(telackey): Should ownership data go here?
|
|
121
121
|
},
|
|
@@ -129,7 +129,7 @@ describe('party-processor', () => {
|
|
|
129
129
|
|
|
130
130
|
const keyAdmit: IHaloStream = {
|
|
131
131
|
meta: {
|
|
132
|
-
feedKey: feedKey.publicKey
|
|
132
|
+
feedKey: feedKey.publicKey,
|
|
133
133
|
seq: 1
|
|
134
134
|
},
|
|
135
135
|
data: createEnvelopeMessage(keyring, partyKey.publicKey,
|
|
@@ -141,7 +141,7 @@ describe('party-processor', () => {
|
|
|
141
141
|
|
|
142
142
|
const feedAdmit2: IHaloStream = {
|
|
143
143
|
meta: {
|
|
144
|
-
feedKey: feedKey.publicKey
|
|
144
|
+
feedKey: feedKey.publicKey,
|
|
145
145
|
seq: 1
|
|
146
146
|
// TODO(telackey): Should ownership data go here?
|
|
147
147
|
},
|
|
@@ -170,7 +170,7 @@ describe('party-processor', () => {
|
|
|
170
170
|
const partyProcessor = new PartyProcessor(partyKey.publicKey);
|
|
171
171
|
expect(partyProcessor.partyKey).toBeTruthy();
|
|
172
172
|
|
|
173
|
-
const meta = (seq: number) => ({ feedKey: feedKey.publicKey
|
|
173
|
+
const meta = (seq: number) => ({ feedKey: feedKey.publicKey, seq });
|
|
174
174
|
|
|
175
175
|
await partyProcessor.processMessage({
|
|
176
176
|
meta: meta(0),
|
|
@@ -7,11 +7,9 @@ import debug from 'debug';
|
|
|
7
7
|
|
|
8
8
|
import { Event } from '@dxos/async';
|
|
9
9
|
import {
|
|
10
|
-
Authenticator,
|
|
11
10
|
KeyHint,
|
|
12
11
|
KeyRecord,
|
|
13
12
|
PartyState,
|
|
14
|
-
PartyAuthenticator,
|
|
15
13
|
Message as HaloMessage,
|
|
16
14
|
IdentityEventType,
|
|
17
15
|
PartyEventType
|
|
@@ -32,11 +30,10 @@ export interface FeedSetProvider {
|
|
|
32
30
|
*/
|
|
33
31
|
export class PartyProcessor {
|
|
34
32
|
private readonly _state: PartyState;
|
|
35
|
-
private readonly _authenticator: Authenticator;
|
|
36
33
|
|
|
37
34
|
private _outboundHaloStream: FeedWriter<HaloMessage> | undefined;
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
readonly feedAdded = new Event<FeedKey>()
|
|
40
37
|
|
|
41
38
|
public readonly keyOrInfoAdded = new Event<PublicKey>();
|
|
42
39
|
|
|
@@ -49,21 +46,14 @@ export class PartyProcessor {
|
|
|
49
46
|
private readonly _partyKey: PartyKey
|
|
50
47
|
) {
|
|
51
48
|
this._state = new PartyState(this._partyKey);
|
|
52
|
-
this._authenticator = new PartyAuthenticator(this._state);
|
|
53
|
-
|
|
54
|
-
/* TODO(telackey): `@dxos/credentials` was only half converted to TS. In its current state, the KeyRecord type
|
|
55
|
-
* is not exported, and the PartyStateMachine being used is not properly understood as an EventEmitter by TS.
|
|
56
|
-
* Casting to 'any' is a workaround for the compiler, but the fix is fully to convert @dxos/credentials to TS.
|
|
57
|
-
*/
|
|
58
|
-
const state = this._state as any;
|
|
59
49
|
|
|
60
50
|
// TODO(marik-d): Use `Event.wrap` here.
|
|
61
|
-
|
|
51
|
+
this._state.on(PartyEventType.ADMIT_FEED, (keyRecord: any) => {
|
|
62
52
|
log(`Feed key admitted ${keyRecord.publicKey.toHex()}`);
|
|
63
|
-
this.
|
|
53
|
+
this.feedAdded.emit(keyRecord.publicKey);
|
|
64
54
|
});
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
this._state.on(PartyEventType.ADMIT_KEY, (keyRecord: KeyRecord) => this.keyOrInfoAdded.emit(keyRecord.publicKey));
|
|
56
|
+
this._state.on(IdentityEventType.UPDATE_IDENTITY, (publicKey: PublicKey) => this.keyOrInfoAdded.emit(publicKey));
|
|
67
57
|
}
|
|
68
58
|
|
|
69
59
|
get partyKey () {
|
|
@@ -90,8 +80,8 @@ export class PartyProcessor {
|
|
|
90
80
|
return this._state.credentialMessages.size === 0;
|
|
91
81
|
}
|
|
92
82
|
|
|
93
|
-
get
|
|
94
|
-
return this.
|
|
83
|
+
get state () {
|
|
84
|
+
return this._state;
|
|
95
85
|
}
|
|
96
86
|
|
|
97
87
|
isFeedAdmitted (feedKey: FeedKey) {
|
|
@@ -122,7 +112,7 @@ export class PartyProcessor {
|
|
|
122
112
|
getActiveFeedSet (): FeedSetProvider {
|
|
123
113
|
return {
|
|
124
114
|
get: () => this.feedKeys,
|
|
125
|
-
added: this.
|
|
115
|
+
added: this.feedAdded
|
|
126
116
|
};
|
|
127
117
|
}
|
|
128
118
|
|
|
@@ -144,7 +144,7 @@ export class PartyProtocolFactory {
|
|
|
144
144
|
/**
|
|
145
145
|
* Creates the protocol plugin for feed replication.
|
|
146
146
|
*/
|
|
147
|
-
class ReplicatorProtocolPluginFactory {
|
|
147
|
+
export class ReplicatorProtocolPluginFactory {
|
|
148
148
|
constructor (
|
|
149
149
|
private readonly _feedProvider: PartyFeedProvider,
|
|
150
150
|
private readonly _activeFeeds: FeedSetProvider
|
|
@@ -12,7 +12,7 @@ import { createId, createKeyPair, PublicKey } from '@dxos/crypto';
|
|
|
12
12
|
import { codec, createFeedWriter, FeedSelector, FeedStoreIterator, IEchoStream, Timeframe } from '@dxos/echo-protocol';
|
|
13
13
|
import { FeedStore, createWritableFeedStream, createWritable, WritableArray } from '@dxos/feed-store';
|
|
14
14
|
import { createSetPropertyMutation } from '@dxos/model-factory';
|
|
15
|
-
import { createStorage,
|
|
15
|
+
import { createStorage, StorageType } from '@dxos/random-access-multi-storage';
|
|
16
16
|
import { jsonReplacer } from '@dxos/util';
|
|
17
17
|
|
|
18
18
|
import { TimeframeClock } from '../database';
|
|
@@ -24,7 +24,7 @@ const log = debug('dxos:echo:pipeline:test');
|
|
|
24
24
|
// TODO(burdon): Test read-only.
|
|
25
25
|
describe('pipeline', () => {
|
|
26
26
|
test('streams', async () => {
|
|
27
|
-
const storage = createStorage('',
|
|
27
|
+
const storage = createStorage('', StorageType.RAM);
|
|
28
28
|
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
29
29
|
const feedKeys: Uint8Array[] = [];
|
|
30
30
|
const feedSelector: FeedSelector = descriptor => !!feedKeys.find(key => descriptor.key.equals(key));
|
|
@@ -52,7 +52,7 @@ describe('pipeline', () => {
|
|
|
52
52
|
await partyProcessor.processMessage({
|
|
53
53
|
data: createPartyGenesisMessage(keyring, partyKey, feedKey.publicKey, identityKey),
|
|
54
54
|
meta: {
|
|
55
|
-
feedKey: feedKey.publicKey
|
|
55
|
+
feedKey: feedKey.publicKey,
|
|
56
56
|
seq: 0
|
|
57
57
|
}
|
|
58
58
|
});
|
|
@@ -86,7 +86,7 @@ describe('pipeline', () => {
|
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
test('writing', async () => {
|
|
89
|
-
const storage = createStorage('',
|
|
89
|
+
const storage = createStorage('', StorageType.RAM);
|
|
90
90
|
const feedStore = new FeedStore(storage, { valueEncoding: codec });
|
|
91
91
|
const feedReadStream = new FeedStoreIterator(() => true, () => 0, new Timeframe());
|
|
92
92
|
|
package/src/pipeline/pipeline.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { createStorage,
|
|
5
|
+
import { StorageType, createStorage, File, IStorage } from '@dxos/random-access-multi-storage';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* A wrapper around RAM storage that preserves file data when closing and re-opening files.
|
|
@@ -10,8 +10,8 @@ import { createStorage, IFile, IStorage } from '@dxos/random-access-multi-storag
|
|
|
10
10
|
// TODO(burdon): Factor out?
|
|
11
11
|
export function createRamStorage (): IStorage {
|
|
12
12
|
const root = 'snapshots';
|
|
13
|
-
const storage = createStorage(root,
|
|
14
|
-
const files = new Map<string,
|
|
13
|
+
const storage = createStorage(root, StorageType.RAM);
|
|
14
|
+
const files = new Map<string, File>();
|
|
15
15
|
|
|
16
16
|
const fn: any = {};
|
|
17
17
|
|