Skip to content

Commit 2ddbf7f

Browse files
committed
wip
1 parent 4785518 commit 2ddbf7f

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

yarn-project/pxe/src/storage/tagging_data_provider/tagging_data_provider.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,50 @@ export class TaggingDataProvider {
99
#store: AztecAsyncKVStore;
1010
#addressBook: AztecAsyncMap<string, true>;
1111

12-
// Stores the last index used for each tagging secret, taking direction into account
13-
// This is necessary to avoid reusing the same index for the same secret, which happens if
14-
// sender and recipient are the same
15-
#taggingSecretIndexesForSenders: AztecAsyncMap<string, number>;
16-
#taggingSecretIndexesForRecipients: AztecAsyncMap<string, number>;
12+
// Stores the last index used for each directional app tagging secret, taking into account whether we are requesting
13+
// the index as a sender or as a recipient because the sender and recipient can be in the same PXE.
14+
#taggingSecretIndexesAsSenders: AztecAsyncMap<string, number>;
15+
#taggingSecretIndexesAsRecipients: AztecAsyncMap<string, number>;
1716

1817
constructor(store: AztecAsyncKVStore) {
1918
this.#store = store;
2019

2120
this.#addressBook = this.#store.openMap('address_book');
2221

23-
this.#taggingSecretIndexesForSenders = this.#store.openMap('tagging_secret_indexes_for_senders');
24-
this.#taggingSecretIndexesForRecipients = this.#store.openMap('tagging_secret_indexes_for_recipients');
22+
this.#taggingSecretIndexesAsSenders = this.#store.openMap('tagging_secret_indexes_as_senders');
23+
this.#taggingSecretIndexesAsRecipients = this.#store.openMap('tagging_secret_indexes_as_recipients');
2524
}
2625

2726
setTaggingSecretIndexAsSender(directionalAppTaggingSecret: Fr, index: number) {
28-
return this.#taggingSecretIndexesForSenders.set(directionalAppTaggingSecret.toString(), index);
27+
return this.#taggingSecretIndexesAsSenders.set(directionalAppTaggingSecret.toString(), index);
2928
}
3029

3130
setTaggingSecretsIndexesAsRecipient(indexedTaggingSecrets: IndexedTaggingSecret[]) {
3231
return Promise.all(
3332
indexedTaggingSecrets.map(({ directionalAppTaggingSecret, index }) =>
34-
this.#taggingSecretIndexesForRecipients.set(`${directionalAppTaggingSecret.toString()}`, index),
33+
this.#taggingSecretIndexesAsRecipients.set(`${directionalAppTaggingSecret.toString()}`, index),
3534
),
3635
);
3736
}
3837

3938
async getTaggingSecretsIndexAsSender(directionalAppTaggingSecret: Fr): Promise<number> {
40-
return (await this.#taggingSecretIndexesForSenders.getAsync(directionalAppTaggingSecret.toString())) ?? 0;
39+
return (await this.#taggingSecretIndexesAsSenders.getAsync(directionalAppTaggingSecret.toString())) ?? 0;
4140
}
4241

4342
getTaggingSecretsIndexesAsRecipient(directionalAppTaggingSecrets: Fr[]): Promise<number[]> {
4443
return Promise.all(
4544
directionalAppTaggingSecrets.map(
46-
async secret => (await this.#taggingSecretIndexesForRecipients.getAsync(secret.toString())) ?? 0,
45+
async secret => (await this.#taggingSecretIndexesAsRecipients.getAsync(secret.toString())) ?? 0,
4746
),
4847
);
4948
}
5049

5150
resetNoteSyncData(): Promise<void> {
5251
return this.#store.transactionAsync(async () => {
53-
const keysForSenders = await toArray(this.#taggingSecretIndexesForSenders.keysAsync());
54-
await Promise.all(keysForSenders.map(secret => this.#taggingSecretIndexesForSenders.delete(secret)));
55-
const keysForRecipients = await toArray(this.#taggingSecretIndexesForRecipients.keysAsync());
56-
await Promise.all(keysForRecipients.map(secret => this.#taggingSecretIndexesForRecipients.delete(secret)));
52+
const keysForSenders = await toArray(this.#taggingSecretIndexesAsSenders.keysAsync());
53+
await Promise.all(keysForSenders.map(secret => this.#taggingSecretIndexesAsSenders.delete(secret)));
54+
const keysForRecipients = await toArray(this.#taggingSecretIndexesAsRecipients.keysAsync());
55+
await Promise.all(keysForRecipients.map(secret => this.#taggingSecretIndexesAsRecipients.delete(secret)));
5756
});
5857
}
5958

0 commit comments

Comments
 (0)