@requestnetwork/data-access 0.23.1-next.1351 → 0.23.1-next.709

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