@requestnetwork/data-access 0.28.1-next.1937 → 0.28.1-next.1938

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.
Files changed (60) hide show
  1. package/dist/combined-data-access.d.ts +0 -1
  2. package/dist/combined-data-access.d.ts.map +1 -1
  3. package/dist/combined-data-access.js.map +1 -1
  4. package/dist/data-read.d.ts +17 -0
  5. package/dist/data-read.d.ts.map +1 -0
  6. package/dist/data-read.js +158 -0
  7. package/dist/data-read.js.map +1 -0
  8. package/dist/data-write.d.ts +10 -0
  9. package/dist/data-write.d.ts.map +1 -0
  10. package/dist/data-write.js +48 -0
  11. package/dist/data-write.js.map +1 -0
  12. package/dist/in-memory-indexer.d.ts +18 -0
  13. package/dist/in-memory-indexer.d.ts.map +1 -0
  14. package/dist/in-memory-indexer.js +107 -0
  15. package/dist/in-memory-indexer.js.map +1 -0
  16. package/dist/index.d.ts +5 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +9 -5
  19. package/dist/index.js.map +1 -1
  20. package/dist/mock-data-access.d.ts +13 -0
  21. package/dist/mock-data-access.d.ts.map +1 -0
  22. package/dist/mock-data-access.js +29 -0
  23. package/dist/mock-data-access.js.map +1 -0
  24. package/dist/pending-store.d.ts +16 -0
  25. package/dist/pending-store.d.ts.map +1 -0
  26. package/dist/pending-store.js +33 -0
  27. package/dist/pending-store.js.map +1 -0
  28. package/dist/types.d.ts +7 -0
  29. package/dist/types.d.ts.map +1 -0
  30. package/dist/types.js +3 -0
  31. package/dist/types.js.map +1 -0
  32. package/package.json +5 -9
  33. package/dist/data-access.d.ts +0 -148
  34. package/dist/data-access.d.ts.map +0 -1
  35. package/dist/data-access.js +0 -428
  36. package/dist/data-access.js.map +0 -1
  37. package/dist/ignored-location.d.ts +0 -58
  38. package/dist/ignored-location.d.ts.map +0 -1
  39. package/dist/ignored-location.js +0 -96
  40. package/dist/ignored-location.js.map +0 -1
  41. package/dist/interval-timer.d.ts +0 -41
  42. package/dist/interval-timer.d.ts.map +0 -1
  43. package/dist/interval-timer.js +0 -94
  44. package/dist/interval-timer.js.map +0 -1
  45. package/dist/transaction-index/index.d.ts +0 -5
  46. package/dist/transaction-index/index.d.ts.map +0 -1
  47. package/dist/transaction-index/index.js +0 -8
  48. package/dist/transaction-index/index.js.map +0 -1
  49. package/dist/transaction-index/location-by-topic.d.ts +0 -53
  50. package/dist/transaction-index/location-by-topic.d.ts.map +0 -1
  51. package/dist/transaction-index/location-by-topic.js +0 -103
  52. package/dist/transaction-index/location-by-topic.js.map +0 -1
  53. package/dist/transaction-index/timestamp-by-location.d.ts +0 -60
  54. package/dist/transaction-index/timestamp-by-location.d.ts.map +0 -1
  55. package/dist/transaction-index/timestamp-by-location.js +0 -108
  56. package/dist/transaction-index/timestamp-by-location.js.map +0 -1
  57. package/dist/transaction-index/transaction-index.d.ts +0 -74
  58. package/dist/transaction-index/transaction-index.d.ts.map +0 -1
  59. package/dist/transaction-index/transaction-index.js +0 -204
  60. package/dist/transaction-index/transaction-index.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@requestnetwork/data-access",
3
- "version": "0.28.1-next.1937+9414820b",
3
+ "version": "0.28.1-next.1938+9021cf2d",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -39,17 +39,13 @@
39
39
  "test:watch": "yarn test --watch"
40
40
  },
41
41
  "dependencies": {
42
- "@requestnetwork/multi-format": "0.15.12-next.1937+9414820b",
43
- "@requestnetwork/types": "0.37.1-next.1937+9414820b",
44
- "@requestnetwork/utils": "0.37.1-next.1937+9414820b",
45
- "bluebird": "3.7.2",
46
- "keyv": "4.0.3",
42
+ "@requestnetwork/multi-format": "0.15.12-next.1938+9021cf2d",
43
+ "@requestnetwork/types": "0.37.1-next.1938+9021cf2d",
44
+ "@requestnetwork/utils": "0.37.1-next.1938+9021cf2d",
47
45
  "tslib": "2.5.0"
48
46
  },
49
47
  "devDependencies": {
50
- "@types/bluebird": "3.5.33",
51
48
  "@types/jest": "26.0.13",
52
- "@types/keyv": "3.1.1",
53
49
  "@types/node": "16.11.7",
54
50
  "jest": "26.4.2",
55
51
  "nyc": "15.1.0",
@@ -59,5 +55,5 @@
59
55
  "ts-node": "10.9.1",
60
56
  "typescript": "4.9.5"
61
57
  },
62
- "gitHead": "9414820b63b4512d8857580e171bd44b52a1c880"
58
+ "gitHead": "9021cf2d70f1908645d1a35113ed7936a98a31f7"
63
59
  }
@@ -1,148 +0,0 @@
1
- import { DataAccessTypes, LogTypes, StorageTypes } from '@requestnetwork/types';
2
- import IgnoredLocationIndex from './ignored-location';
3
- /**
4
- * Options for the DataAccess initialization
5
- */
6
- export interface IDataAccessOptions {
7
- /**
8
- * Logger instance
9
- */
10
- logger: LogTypes.ILogger;
11
- /**
12
- * the transaction index, defaults to TransactionIndex if not set.
13
- */
14
- transactionIndex: DataAccessTypes.ITransactionIndex;
15
- /**
16
- * synchronizationIntervalTime Interval time between each synchronization
17
- * Defaults to DEFAULT_INTERVAL_TIME.
18
- */
19
- synchronizationIntervalTime: number;
20
- /**
21
- * Index of the ignored location with the reason
22
- */
23
- ignoredLocationIndex: IgnoredLocationIndex;
24
- /**
25
- * Specifies whether to start the synchronization on initialization
26
- */
27
- autoStartSynchronization: boolean;
28
- }
29
- /**
30
- * Implementation of Data-Access layer without encryption
31
- */
32
- export default class DataAccess implements DataAccessTypes.IDataAccess {
33
- private transactionIndex;
34
- protected isInitialized: boolean;
35
- private storage;
36
- private ignoredLocationIndex;
37
- private synchronizationTimer;
38
- /**
39
- * Specifies whether to start the synchronization on initialization
40
- */
41
- private autoStartSynchronization;
42
- private lastSyncStorageTimestamp;
43
- /**
44
- * Logger instance
45
- */
46
- private logger;
47
- /**
48
- * Constructor DataAccess interface
49
- *
50
- * @param IStorage storage storage object
51
- */
52
- constructor(storage: StorageTypes.IStorage, options?: Partial<IDataAccessOptions>);
53
- /**
54
- * Function to initialize the dataId topic with the previous block
55
- */
56
- initialize(): Promise<void>;
57
- close(): Promise<void>;
58
- /**
59
- * Function to persist transaction and topic in storage
60
- * For now, we create a block for each transaction
61
- *
62
- * @param transaction transaction to persist
63
- * @param channelId string to identify a bunch of transaction
64
- * @param topics list of string to topic the transaction
65
- *
66
- * @returns string dataId where the transaction is stored
67
- */
68
- persistTransaction(transaction: DataAccessTypes.ITransaction, channelId: string, topics?: string[]): Promise<DataAccessTypes.IReturnPersistTransaction>;
69
- /**
70
- * Function to get a list of transactions indexed by channel id
71
- * if timestampBoundaries is given, the search will be restrict from timestamp 'from' to the timestamp 'to'.
72
- * if timestampBoundaries.from is not given, the search will be start from the very start
73
- * if timestampBoundaries.to is not given, the search will be stop at the current timestamp
74
- *
75
- * @param channelId channel id to retrieve the transaction from
76
- * @param timestampBoundaries timestamp boundaries of the transactions search
77
- *
78
- * @returns list of transactions in the channel
79
- */
80
- getTransactionsByChannelId(channelId: string, timestampBoundaries?: DataAccessTypes.ITimestampBoundaries): Promise<DataAccessTypes.IReturnGetTransactions>;
81
- /**
82
- * Function to get a list of channels indexed by topic
83
- *
84
- * @param topic topic to retrieve the channels from
85
- * @param updatedBetween filter the channels that have received new data within the time boundaries
86
- *
87
- * @returns list of channels indexed by topic
88
- */
89
- getChannelsByTopic(topic: string, updatedBetween?: DataAccessTypes.ITimestampBoundaries): Promise<DataAccessTypes.IReturnGetChannelsByTopic>;
90
- /**
91
- * Function to get a list of channels indexed by multiple topics
92
- *
93
- * @param topics topics to retrieve the channels from
94
- * @param updatedBetween filter the channels that have received new data within the time boundaries
95
- *
96
- * @returns list of channels indexed by topics
97
- */
98
- getChannelsByMultipleTopics(topics: string[], updatedBetween?: DataAccessTypes.ITimestampBoundaries): Promise<DataAccessTypes.IReturnGetChannelsByTopic>;
99
- /**
100
- * Function to synchronize with the new dataIds on the storage
101
- */
102
- synchronizeNewDataIds(): Promise<void>;
103
- /**
104
- * Start to synchronize with the storage automatically
105
- * Once called, synchronizeNewDataId function is called periodically
106
- */
107
- startAutoSynchronization(): void;
108
- /**
109
- * Stop to synchronize with the storage automatically
110
- */
111
- stopAutoSynchronization(): Promise<void>;
112
- /**
113
- * Gets information of the data indexed
114
- *
115
- * @param detailed if true get the list of the files hashes
116
- */
117
- _getStatus(detailed?: boolean): Promise<DataAccessTypes.IDataAccessStatus>;
118
- /**
119
- * Check the format of the data, extract the topics from it and push location indexed with the topics
120
- *
121
- * @private
122
- * @param entries data with meta from storage functions
123
- * @param locationByTopic LocationByTopic object to push location
124
- */
125
- private pushLocationsWithTopics;
126
- /**
127
- * Gets the blocks and their metadata from an array of storage location
128
- *
129
- * @param storageLocationList array of storage location
130
- * @returns the blocks and their metadata
131
- */
132
- private getBlockAndMetaFromStorageLocation;
133
- /**
134
- * Gets the transactions and their metadata from a block and an array of transaction positions
135
- *
136
- * @param transactionPositions transaction positions to retrieve
137
- * @param block the block
138
- * @param location location of the block
139
- * @param meta metadata of the block
140
- * @returns the transactions and their metadata
141
- */
142
- private getTransactionAndMetaFromPosition;
143
- /**
144
- * Throws an error if the data access isn't initialized
145
- */
146
- private checkInitialized;
147
- }
148
- //# sourceMappingURL=data-access.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-access.d.ts","sourceRoot":"","sources":["../src/data-access.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAOhF,OAAO,oBAAoB,MAAM,oBAAoB,CAAC;AAOtD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC;IAEzB;;OAEG;IACH,gBAAgB,EAAE,eAAe,CAAC,iBAAiB,CAAC;IAEpD;;;OAGG;IACH,2BAA2B,EAAE,MAAM,CAAC;IAEpC;;OAEG;IACH,oBAAoB,EAAE,oBAAoB,CAAC;IAE3C;;OAEG;IACH,wBAAwB,EAAE,OAAO,CAAC;CACnC;AAUD;;GAEG;AAC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,CAAC;IA4BnD;;;OAGG;IACI,wBAAwB,IAAI,IAAI;IAKvC;;OAEG;IACU,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;IAMrD;;;;OAIG;IACU,UAAU,CAAC,QAAQ,UAAQ,GAAG,OAAO,CAAC,eAAe,CAAC,iBAAiB,CAAC;IA0BrF;;;;;;OAMG;YACW,uBAAuB;IAmCrC;;;;;OAKG;YACW,kCAAkC;IAmBhD;;;;;;;;OAQG;IACH,OAAO,CAAC,iCAAiC;IAkCzC;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAKzB"}
@@ -1,428 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const multi_format_1 = require("@requestnetwork/multi-format");
5
- const types_1 = require("@requestnetwork/types");
6
- const utils_1 = require("@requestnetwork/utils");
7
- const Bluebird = require("bluebird");
8
- const events_1 = require("events");
9
- const block_1 = require("./block");
10
- const ignored_location_1 = require("./ignored-location");
11
- const interval_timer_1 = require("./interval-timer");
12
- const transaction_index_1 = require("./transaction-index");
13
- // Default interval time for auto synchronization
14
- const DEFAULT_INTERVAL_TIME = 10000;
15
- const emptyChannelsWithTopics = {
16
- meta: {
17
- storageMeta: {},
18
- transactionsStorageLocation: {},
19
- },
20
- result: { transactions: {} },
21
- };
22
- /**
23
- * Implementation of Data-Access layer without encryption
24
- */
25
- class DataAccess {
26
- /**
27
- * Constructor DataAccess interface
28
- *
29
- * @param IStorage storage storage object
30
- */
31
- constructor(storage, options) {
32
- // boolean to store the initialization state
33
- this.isInitialized = false;
34
- const defaultOptions = {
35
- ignoredLocationIndex: new ignored_location_1.default(),
36
- logger: new utils_1.SimpleLogger(),
37
- synchronizationIntervalTime: DEFAULT_INTERVAL_TIME,
38
- transactionIndex: new transaction_index_1.default(),
39
- autoStartSynchronization: false,
40
- };
41
- const { ignoredLocationIndex, logger, synchronizationIntervalTime, transactionIndex, autoStartSynchronization, } = Object.assign(Object.assign({}, defaultOptions), options);
42
- this.storage = storage;
43
- this.lastSyncStorageTimestamp = 0;
44
- this.autoStartSynchronization = autoStartSynchronization;
45
- this.synchronizationTimer = new interval_timer_1.default(() => this.synchronizeNewDataIds(), synchronizationIntervalTime, logger, 5);
46
- this.transactionIndex = transactionIndex;
47
- this.ignoredLocationIndex = ignoredLocationIndex;
48
- this.logger = logger;
49
- }
50
- /**
51
- * Function to initialize the dataId topic with the previous block
52
- */
53
- initialize() {
54
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
55
- if (this.isInitialized) {
56
- throw new Error('already initialized');
57
- }
58
- yield this.transactionIndex.initialize();
59
- // initialize storage
60
- yield this.storage.initialize();
61
- // if transaction index already has data, then sync from the last available timestamp
62
- const lastSynced = yield this.transactionIndex.getLastTransactionTimestamp();
63
- const now = (0, utils_1.getCurrentTimestampInSecond)();
64
- // initialize the dataId topic with the previous block
65
- const allDataWithMeta = yield this.storage.getData(lastSynced
66
- ? {
67
- from: lastSynced,
68
- to: now,
69
- }
70
- : undefined);
71
- // The last synced timestamp is the latest one returned by storage
72
- this.lastSyncStorageTimestamp = allDataWithMeta.lastTimestamp;
73
- // check if the data returned by getData are correct
74
- // if yes, the dataIds are indexed with LocationByTopic
75
- yield this.pushLocationsWithTopics(allDataWithMeta.entries);
76
- this.isInitialized = true;
77
- if (this.autoStartSynchronization) {
78
- this.startAutoSynchronization();
79
- }
80
- });
81
- }
82
- close() {
83
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
84
- yield this.stopAutoSynchronization();
85
- });
86
- }
87
- /**
88
- * Function to persist transaction and topic in storage
89
- * For now, we create a block for each transaction
90
- *
91
- * @param transaction transaction to persist
92
- * @param channelId string to identify a bunch of transaction
93
- * @param topics list of string to topic the transaction
94
- *
95
- * @returns string dataId where the transaction is stored
96
- */
97
- persistTransaction(transaction, channelId, topics = []) {
98
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
99
- this.checkInitialized();
100
- // get all the topics not well formatted
101
- const notFormattedTopics = topics.filter((topic) => !multi_format_1.default.hashFormat.isDeserializableString(topic));
102
- if (notFormattedTopics.length !== 0) {
103
- throw new Error(`The following topics are not well formatted: ${JSON.stringify(notFormattedTopics)}`);
104
- }
105
- // create a block and add the transaction in it
106
- const updatedBlock = block_1.default.pushTransaction(block_1.default.createEmptyBlock(), transaction, channelId, topics);
107
- // get the topic of the data in storage
108
- const resultAppend = yield this.storage.append(JSON.stringify(updatedBlock));
109
- const result = Object.assign(new events_1.EventEmitter(), {
110
- meta: {
111
- storageMeta: resultAppend.meta,
112
- topics,
113
- transactionStorageLocation: resultAppend.id,
114
- },
115
- result: {},
116
- });
117
- // Store the data to the real storage
118
- resultAppend
119
- .on('confirmed', (resultAppendConfirmed) => tslib_1.__awaiter(this, void 0, void 0, function* () {
120
- // update the timestamp with the confirmed one
121
- yield this.transactionIndex.updateTimestamp(resultAppendConfirmed.id, resultAppendConfirmed.meta.timestamp);
122
- const resultAfterConfirmation = {
123
- meta: {
124
- storageMeta: resultAppendConfirmed.meta,
125
- topics,
126
- transactionStorageLocation: resultAppendConfirmed.id,
127
- },
128
- result: {},
129
- };
130
- result.emit('confirmed', resultAfterConfirmation);
131
- }))
132
- .on('error', (error) => tslib_1.__awaiter(this, void 0, void 0, function* () {
133
- result.emit('error', error);
134
- }));
135
- // adds this transaction to the index, to enable retrieving it later.
136
- yield this.transactionIndex.addTransaction(resultAppend.id, updatedBlock.header, resultAppend.meta.timestamp);
137
- return result;
138
- });
139
- }
140
- /**
141
- * Function to get a list of transactions indexed by channel id
142
- * if timestampBoundaries is given, the search will be restrict from timestamp 'from' to the timestamp 'to'.
143
- * if timestampBoundaries.from is not given, the search will be start from the very start
144
- * if timestampBoundaries.to is not given, the search will be stop at the current timestamp
145
- *
146
- * @param channelId channel id to retrieve the transaction from
147
- * @param timestampBoundaries timestamp boundaries of the transactions search
148
- *
149
- * @returns list of transactions in the channel
150
- */
151
- getTransactionsByChannelId(channelId, timestampBoundaries) {
152
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
153
- this.checkInitialized();
154
- // Gets the list of locationStorage indexed by the channel id that are within the boundaries
155
- const storageLocationList = yield this.transactionIndex.getStorageLocationList(channelId, timestampBoundaries);
156
- // Gets the block and meta from the storage location
157
- const blockWithMetaList = yield this.getBlockAndMetaFromStorageLocation(storageLocationList);
158
- // Get the transactions (and the meta) indexed by channelIds in the blocks found
159
- const transactionsAndMetaPerBlocks =
160
- // for all the blocks found
161
- blockWithMetaList.map((blockAndMeta) => {
162
- // Gets the list of positions of the transaction needed from the block
163
- const transactionPositions = block_1.default.getTransactionPositionFromChannelId(blockAndMeta.block, channelId);
164
- return this.getTransactionAndMetaFromPosition(transactionPositions, blockAndMeta.block, blockAndMeta.location, blockAndMeta.meta);
165
- });
166
- // Creates the result by concatenating the transactions and meta of every blocks
167
- return transactionsAndMetaPerBlocks.reduce((accumulator, elem) => ({
168
- meta: {
169
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
170
- storageMeta: accumulator.meta.storageMeta.concat(elem.storageMeta),
171
- transactionsStorageLocation: accumulator.meta.transactionsStorageLocation.concat(elem.transactionsStorageLocation),
172
- },
173
- result: {
174
- transactions: accumulator.result.transactions.concat(elem.transactions),
175
- },
176
- }),
177
- // initial value is full of empty arrays
178
- {
179
- meta: { storageMeta: [], transactionsStorageLocation: [] },
180
- result: { transactions: [] },
181
- });
182
- });
183
- }
184
- /**
185
- * Function to get a list of channels indexed by topic
186
- *
187
- * @param topic topic to retrieve the channels from
188
- * @param updatedBetween filter the channels that have received new data within the time boundaries
189
- *
190
- * @returns list of channels indexed by topic
191
- */
192
- getChannelsByTopic(topic, updatedBetween) {
193
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
194
- this.checkInitialized();
195
- // check if the topic is well formatted
196
- if (!multi_format_1.default.hashFormat.isDeserializableString(topic)) {
197
- throw new Error(`The topic is not well formatted: ${topic}`);
198
- }
199
- const channelIds = yield this.transactionIndex.getChannelIdsForTopic(topic, updatedBetween);
200
- // Gets the transactions per channel id
201
- const transactionsAndMeta = Bluebird.map(channelIds, (channelId) => this.getTransactionsByChannelId(channelId).then((transactionsWithMeta) => ({
202
- channelId,
203
- transactionsWithMeta,
204
- })));
205
- // Gather all the transactions in one object
206
- return transactionsAndMeta.reduce((finalResult, channelIdAndTransactions) => {
207
- const id = channelIdAndTransactions.channelId;
208
- // Adds the storage location of the channel's data
209
- finalResult.meta.transactionsStorageLocation[id] =
210
- channelIdAndTransactions.transactionsWithMeta.meta.transactionsStorageLocation;
211
- // Adds the meta of the channel
212
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
213
- finalResult.meta.storageMeta[id] =
214
- channelIdAndTransactions.transactionsWithMeta.meta.storageMeta;
215
- // Adds the transaction of the channel
216
- finalResult.result.transactions[id] =
217
- channelIdAndTransactions.transactionsWithMeta.result.transactions;
218
- return finalResult;
219
- }, (0, utils_1.deepCopy)(emptyChannelsWithTopics));
220
- });
221
- }
222
- /**
223
- * Function to get a list of channels indexed by multiple topics
224
- *
225
- * @param topics topics to retrieve the channels from
226
- * @param updatedBetween filter the channels that have received new data within the time boundaries
227
- *
228
- * @returns list of channels indexed by topics
229
- */
230
- getChannelsByMultipleTopics(topics, updatedBetween) {
231
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
232
- this.checkInitialized();
233
- if (topics.some((topic) => !multi_format_1.default.hashFormat.isDeserializableString(topic))) {
234
- throw new Error(`The topics are not well formatted`);
235
- }
236
- const channelIds = yield this.transactionIndex.getChannelIdsForMultipleTopics(topics, updatedBetween);
237
- // Gets the transactions per channel id
238
- const transactionsAndMeta = Bluebird.map(channelIds, (channelId) => this.getTransactionsByChannelId(channelId).then((transactionsWithMeta) => ({
239
- channelId,
240
- transactionsWithMeta,
241
- })));
242
- // Gather all the transactions in one object
243
- return transactionsAndMeta.reduce((finalResult, channelIdAndTransactions) => {
244
- const id = channelIdAndTransactions.channelId;
245
- // Adds the storage location of the channel's data
246
- finalResult.meta.transactionsStorageLocation[id] =
247
- channelIdAndTransactions.transactionsWithMeta.meta.transactionsStorageLocation;
248
- // Adds the meta of the channel
249
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
250
- finalResult.meta.storageMeta[id] =
251
- channelIdAndTransactions.transactionsWithMeta.meta.storageMeta;
252
- // Adds the transaction of the channel
253
- finalResult.result.transactions[id] =
254
- channelIdAndTransactions.transactionsWithMeta.result.transactions;
255
- return finalResult;
256
- }, (0, utils_1.deepCopy)(emptyChannelsWithTopics));
257
- });
258
- }
259
- /**
260
- * Function to synchronize with the new dataIds on the storage
261
- */
262
- synchronizeNewDataIds() {
263
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
264
- this.checkInitialized();
265
- const synchronizationTo = (0, utils_1.getCurrentTimestampInSecond)();
266
- // We increment lastSyncStorageTimestamp because the data located at lastSyncStorageTimestamp
267
- // 0 means it's the first synchronization
268
- let synchronizationFrom = 0;
269
- if (this.lastSyncStorageTimestamp > 0) {
270
- synchronizationFrom = this.lastSyncStorageTimestamp + 1;
271
- }
272
- // Read new data from storage
273
- const newDataWithMeta = yield this.storage.getData({
274
- from: synchronizationFrom,
275
- to: synchronizationTo,
276
- });
277
- // Try to get some data previously ignored
278
- const oldEntriesWithMeta = yield this.storage.getIgnoredData();
279
- // check if the data returned by getNewDataId are correct
280
- // if yes, the dataIds are indexed with LocationByTopic
281
- yield this.pushLocationsWithTopics(newDataWithMeta.entries.concat(oldEntriesWithMeta));
282
- // The last synced timestamp is the latest one returned by storage
283
- this.lastSyncStorageTimestamp = newDataWithMeta.lastTimestamp;
284
- });
285
- }
286
- /**
287
- * Start to synchronize with the storage automatically
288
- * Once called, synchronizeNewDataId function is called periodically
289
- */
290
- startAutoSynchronization() {
291
- this.checkInitialized();
292
- this.synchronizationTimer.start();
293
- }
294
- /**
295
- * Stop to synchronize with the storage automatically
296
- */
297
- stopAutoSynchronization() {
298
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
299
- if (this.synchronizationTimer.isStarted) {
300
- yield this.synchronizationTimer.stop();
301
- }
302
- });
303
- }
304
- /**
305
- * Gets information of the data indexed
306
- *
307
- * @param detailed if true get the list of the files hashes
308
- */
309
- _getStatus(detailed = false) {
310
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
311
- this.checkInitialized();
312
- // last transaction timestamp retrieved
313
- const lastLocationTimestamp = yield this.transactionIndex.getLastTransactionTimestamp();
314
- const listIndexedLocation = yield this.transactionIndex.getIndexedLocations();
315
- const listIgnoredLocationIndex = yield this.ignoredLocationIndex.getIgnoredLocations();
316
- const synchronizationConfig = this.synchronizationTimer.getConfig();
317
- return {
318
- filesIgnored: {
319
- count: Object.keys(listIgnoredLocationIndex).length,
320
- list: detailed ? listIgnoredLocationIndex : undefined,
321
- },
322
- filesRetrieved: {
323
- count: listIndexedLocation.length,
324
- lastTimestamp: lastLocationTimestamp,
325
- list: detailed ? listIndexedLocation : undefined,
326
- },
327
- lastSynchronizationTimestamp: this.lastSyncStorageTimestamp,
328
- storage: yield this.storage._getStatus(detailed),
329
- synchronizationConfig,
330
- };
331
- });
332
- }
333
- /**
334
- * Check the format of the data, extract the topics from it and push location indexed with the topics
335
- *
336
- * @private
337
- * @param entries data with meta from storage functions
338
- * @param locationByTopic LocationByTopic object to push location
339
- */
340
- pushLocationsWithTopics(entries) {
341
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
342
- if (!entries) {
343
- throw Error(`data from storage do not follow the standard`);
344
- }
345
- let parsingErrorCount = 0;
346
- let proceedCount = 0;
347
- yield Bluebird.each(entries, (entry) => tslib_1.__awaiter(this, void 0, void 0, function* () {
348
- if (!entry.content || !entry.id) {
349
- throw Error(`data from storage do not follow the standard`);
350
- }
351
- let block;
352
- const blockString = entry.content;
353
- try {
354
- block = block_1.default.parseBlock(blockString);
355
- proceedCount++;
356
- // adds this transaction to the index, to enable retrieving it later.
357
- yield this.transactionIndex.addTransaction(entry.id, block.header, entry.meta.timestamp);
358
- }
359
- catch (e) {
360
- parsingErrorCount++;
361
- // Index ignored Location
362
- yield this.ignoredLocationIndex.pushReasonByLocation(entry.id, e.message);
363
- this.logger.debug(`Error: can't parse content of the dataId (${entry.id}): ${e}`, [
364
- 'synchronization',
365
- ]);
366
- }
367
- }));
368
- this.logger.info(`Synchronization: ${proceedCount} blocks synchronized, ${parsingErrorCount} ignored from parsing error`, ['synchronization']);
369
- });
370
- }
371
- /**
372
- * Gets the blocks and their metadata from an array of storage location
373
- *
374
- * @param storageLocationList array of storage location
375
- * @returns the blocks and their metadata
376
- */
377
- getBlockAndMetaFromStorageLocation(storageLocationList) {
378
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
379
- // Gets blocks indexed by topic
380
- return Promise.all(storageLocationList.map((location) => tslib_1.__awaiter(this, void 0, void 0, function* () {
381
- const resultRead = yield this.storage.read(location);
382
- return {
383
- block: block_1.default.parseBlock(resultRead.content),
384
- location,
385
- meta: resultRead.meta,
386
- };
387
- })));
388
- });
389
- }
390
- /**
391
- * Gets the transactions and their metadata from a block and an array of transaction positions
392
- *
393
- * @param transactionPositions transaction positions to retrieve
394
- * @param block the block
395
- * @param location location of the block
396
- * @param meta metadata of the block
397
- * @returns the transactions and their metadata
398
- */
399
- getTransactionAndMetaFromPosition(transactionPositions, block, location, meta) {
400
- // Gets the transaction from the positions
401
- const transactions =
402
- // first remove de duplicates
403
- (0, utils_1.unique)(transactionPositions).uniqueItems.map(
404
- // Get the transaction from their position and add the timestamp
405
- (position) => ({
406
- state: meta.state === types_1.StorageTypes.ContentState.CONFIRMED
407
- ? types_1.DataAccessTypes.TransactionState.CONFIRMED
408
- : types_1.DataAccessTypes.TransactionState.PENDING,
409
- timestamp: meta.timestamp,
410
- transaction: block.transactions[position],
411
- }));
412
- // Gets the list of storage location of the transactions found
413
- const transactionsStorageLocation = Array(transactions.length).fill(location);
414
- // Gets the list of storage meta of the transactions found
415
- const storageMeta = transactions.map(() => meta);
416
- return { transactions, transactionsStorageLocation, storageMeta };
417
- }
418
- /**
419
- * Throws an error if the data access isn't initialized
420
- */
421
- checkInitialized() {
422
- if (!this.isInitialized) {
423
- throw new Error('DataAccess must be initialized');
424
- }
425
- }
426
- }
427
- exports.default = DataAccess;
428
- //# sourceMappingURL=data-access.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-access.js","sourceRoot":"","sources":["../src/data-access.ts"],"names":[],"mappings":";;;AAAA,+DAAuD;AACvD,iDAAgF;AAChF,iDAAoG;AAEpG,qCAAqC;AACrC,mCAAsC;AAEtC,mCAA4B;AAC5B,yDAAsD;AACtD,qDAA6C;AAC7C,2DAAmD;AAEnD,iDAAiD;AACjD,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAiCpC,MAAM,uBAAuB,GAA8C;IACzE,IAAI,EAAE;QACJ,WAAW,EAAE,EAAE;QACf,2BAA2B,EAAE,EAAE;KAChC;IACD,MAAM,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAqB,UAAU;IAiC7B;;;;OAIG;IACH,YAAmB,OAA8B,EAAE,OAAqC;QAlCxF,4CAA4C;QAClC,kBAAa,GAAG,KAAK,CAAC;QAkC9B,MAAM,cAAc,GAAuB;YACzC,oBAAoB,EAAE,IAAI,0BAAoB,EAAE;YAChD,MAAM,EAAE,IAAI,oBAAY,EAAE;YAC1B,2BAA2B,EAAE,qBAAqB;YAClD,gBAAgB,EAAE,IAAI,2BAAgB,EAAE;YACxC,wBAAwB,EAAE,KAAK;SAChC,CAAC;QACF,MAAM,EACJ,oBAAoB,EACpB,MAAM,EACN,2BAA2B,EAC3B,gBAAgB,EAChB,wBAAwB,GACzB,mCACI,cAAc,GACd,OAAO,CACX,CAAC;QACF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,wBAAwB,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;QACzD,IAAI,CAAC,oBAAoB,GAAG,IAAI,wBAAa,CAC3C,GAAG,EAAE,CAAC,IAAI,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