@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.
- package/README.md +0 -4
- package/dist/block.d.ts +4 -4
- package/dist/block.d.ts.map +1 -1
- package/dist/block.js +9 -9
- package/dist/block.js.map +1 -1
- package/dist/combined-data-access.d.ts +13 -0
- package/dist/combined-data-access.d.ts.map +1 -0
- package/dist/combined-data-access.js +44 -0
- package/dist/combined-data-access.js.map +1 -0
- package/dist/data-read.d.ts +17 -0
- package/dist/data-read.d.ts.map +1 -0
- package/dist/data-read.js +158 -0
- package/dist/data-read.js.map +1 -0
- package/dist/data-write.d.ts +10 -0
- package/dist/data-write.d.ts.map +1 -0
- package/dist/data-write.js +48 -0
- package/dist/data-write.js.map +1 -0
- package/dist/in-memory-indexer.d.ts +18 -0
- package/dist/in-memory-indexer.d.ts.map +1 -0
- package/dist/in-memory-indexer.js +110 -0
- package/dist/in-memory-indexer.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/dist/mock-data-access.d.ts +13 -0
- package/dist/mock-data-access.d.ts.map +1 -0
- package/dist/mock-data-access.js +29 -0
- package/dist/mock-data-access.js.map +1 -0
- package/dist/pending-store.d.ts +16 -0
- package/dist/pending-store.d.ts.map +1 -0
- package/dist/pending-store.js +33 -0
- package/dist/pending-store.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +18 -29
- package/CHANGELOG.md +0 -1466
- package/dist/data-access.d.ts +0 -140
- package/dist/data-access.d.ts.map +0 -1
- package/dist/data-access.js +0 -425
- package/dist/data-access.js.map +0 -1
- package/dist/ignored-location.d.ts +0 -58
- package/dist/ignored-location.d.ts.map +0 -1
- package/dist/ignored-location.js +0 -104
- package/dist/ignored-location.js.map +0 -1
- package/dist/interval-timer.d.ts +0 -36
- package/dist/interval-timer.d.ts.map +0 -1
- package/dist/interval-timer.js +0 -90
- package/dist/interval-timer.js.map +0 -1
- package/dist/transaction-index/index.d.ts +0 -5
- package/dist/transaction-index/index.d.ts.map +0 -1
- package/dist/transaction-index/index.js +0 -17
- package/dist/transaction-index/index.js.map +0 -1
- package/dist/transaction-index/location-by-topic.d.ts +0 -53
- package/dist/transaction-index/location-by-topic.d.ts.map +0 -1
- package/dist/transaction-index/location-by-topic.js +0 -111
- package/dist/transaction-index/location-by-topic.js.map +0 -1
- package/dist/transaction-index/timestamp-by-location.d.ts +0 -60
- package/dist/transaction-index/timestamp-by-location.d.ts.map +0 -1
- package/dist/transaction-index/timestamp-by-location.js +0 -116
- package/dist/transaction-index/timestamp-by-location.js.map +0 -1
- package/dist/transaction-index/transaction-index.d.ts +0 -74
- package/dist/transaction-index/transaction-index.d.ts.map +0 -1
- package/dist/transaction-index/transaction-index.js +0 -212
- package/dist/transaction-index/transaction-index.js.map +0 -1
package/README.md
CHANGED
|
@@ -139,10 +139,6 @@ Transactions are indexed with `topics`. When persisting a transaction on data-ac
|
|
|
139
139
|
|
|
140
140
|
To save on costs, transactions are batched together. This is the responsibility of Data Access layer. This package creates `blocks` that are collections of `transactions`
|
|
141
141
|
|
|
142
|
-
### Cache
|
|
143
|
-
|
|
144
|
-
In order to speed up recovery of transactions, data-access has a local cache of topics=>transaction. This is the reason why this package should be initialized with `dataAccess.initialize()` before being operational. This cache can be persisted in a file using a [Keyv store](https://github.com/lukechilds/keyv#official-storage-adapters).
|
|
145
|
-
|
|
146
142
|
### Synchronization
|
|
147
143
|
|
|
148
144
|
Blocks can be added into the storage by other peers running their own data-access instance. Therefore, to remain consistent with the global state of the network, this package need to synchronize with these new blocks.`dataAccess.synchronizeNewDataIds()` allows to synchronize manually with all unsynchronized blocks. The synchronization can also be done automatically, `dataAccess.startAutoSynchronization()` allows to automatically synchronize with new blocks, the interval time between each synchronization can be defined in data-access constructor. `dataAccess.stopAutoSynchronization()` allows to stop automatic synchronization.
|
package/dist/block.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { DataAccessTypes } from '@requestnetwork/types';
|
|
2
|
+
/**
|
|
3
|
+
* Module to manage a block in the data access-layer
|
|
4
|
+
* a block is a sorted list of transactions with topics
|
|
5
|
+
*/
|
|
2
6
|
declare const _default: {
|
|
3
7
|
createEmptyBlock: typeof createEmptyBlock;
|
|
4
8
|
getAllChannelIds: typeof getAllChannelIds;
|
|
@@ -11,10 +15,6 @@ declare const _default: {
|
|
|
11
15
|
parseBlock: typeof parseBlock;
|
|
12
16
|
pushTransaction: typeof pushTransaction;
|
|
13
17
|
};
|
|
14
|
-
/**
|
|
15
|
-
* Module to manage a block in the data access-layer
|
|
16
|
-
* a block is a sorted list of transactions with topics
|
|
17
|
-
*/
|
|
18
18
|
export default _default;
|
|
19
19
|
/**
|
|
20
20
|
* Function to create an empty block
|
package/dist/block.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD;;;GAGG;;;;;;;;;;;;;AACH,wBAWE;AAEF;;;;GAIG;AACH,iBAAS,gBAAgB,IAAI,eAAe,CAAC,MAAM,CASlD;AAED;;;;;GAKG;AACH,iBAAS,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC,MAAM,CA8DxD;AAED;;;;;;;;;GASG;AACH,iBAAS,eAAe,CACtB,KAAK,EAAE,eAAe,CAAC,MAAM,EAC7B,WAAW,EAAE,eAAe,CAAC,YAAY,EACzC,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,MAAM,EAAO,GACpB,eAAe,CAAC,MAAM,CAuBxB;AAED;;;;;;;GAOG;AACH,iBAAS,0BAA0B,CACjC,KAAK,EAAE,eAAe,CAAC,MAAM,EAC7B,QAAQ,EAAE,MAAM,GACf,eAAe,CAAC,YAAY,CAE9B;AAED;;;;;;;GAOG;AACH,iBAAS,0BAA0B,CACjC,KAAK,EAAE,eAAe,CAAC,MAAM,EAC7B,SAAS,EAAE,MAAM,EAAE,GAClB,eAAe,CAAC,YAAY,EAAE,CAOhC;AAED;;;;;;GAMG;AACH,iBAAS,kBAAkB,CAAC,KAAK,EAAE,eAAe,CAAC,MAAM,GAAG,eAAe,CAAC,YAAY,EAAE,CAEzF;AAED;;;;;;;GAOG;AACH,iBAAS,mCAAmC,CAC1C,KAAK,EAAE,eAAe,CAAC,MAAM,EAC7B,SAAS,EAAE,MAAM,GAChB,MAAM,EAAE,CAEV;AAED;;;;;;;GAOG;AACH,iBAAS,mCAAmC,CAC1C,KAAK,EAAE,eAAe,CAAC,MAAM,EAC7B,UAAU,EAAE,MAAM,EAAE,GACnB,MAAM,EAAE,CAQV;AAED;;;;;;GAMG;AACH,iBAAS,YAAY,CAAC,KAAK,EAAE,eAAe,CAAC,MAAM,GAAG,eAAe,CAAC,OAAO,CAE5E;AAED;;;;;;GAMG;AACH,iBAAS,gBAAgB,CAAC,KAAK,EAAE,eAAe,CAAC,MAAM,GAAG,eAAe,CAAC,WAAW,CAEpF"}
|
package/dist/block.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const MultiFormat = require("@requestnetwork/multi-format");
|
|
4
4
|
const utils_1 = require("@requestnetwork/utils");
|
|
5
5
|
/**
|
|
6
6
|
* Module to manage a block in the data access-layer
|
|
@@ -62,7 +62,7 @@ function parseBlock(data) {
|
|
|
62
62
|
}
|
|
63
63
|
// check if channelIds are well formatted
|
|
64
64
|
// check that all the channel ids are hashes
|
|
65
|
-
if (Object.keys(maybeBlock.header.channelIds).some((channelId) => !
|
|
65
|
+
if (Object.keys(maybeBlock.header.channelIds).some((channelId) => !MultiFormat.hashFormat.isDeserializableString(channelId))) {
|
|
66
66
|
throw new Error(`Channel ids in header.channelIds must be formatted keccak256 hashes`);
|
|
67
67
|
}
|
|
68
68
|
// check if channel ids refer to actual transactions in the block
|
|
@@ -72,11 +72,11 @@ function parseBlock(data) {
|
|
|
72
72
|
}
|
|
73
73
|
// check if topics are well formatted
|
|
74
74
|
// check that all the channel ids are hashes
|
|
75
|
-
if (Object.keys(maybeBlock.header.topics).some((channelId) => !
|
|
75
|
+
if (Object.keys(maybeBlock.header.topics).some((channelId) => !MultiFormat.hashFormat.isDeserializableString(channelId))) {
|
|
76
76
|
throw new Error(`Channel ids in header.topics must be formatted keccak256 hashes`);
|
|
77
77
|
}
|
|
78
78
|
// check if topics are hashes
|
|
79
|
-
if (Object.values(maybeBlock.header.topics).some((listOfTopics) => listOfTopics.some((topic) => !
|
|
79
|
+
if (Object.values(maybeBlock.header.topics).some((listOfTopics) => listOfTopics.some((topic) => !MultiFormat.hashFormat.isDeserializableString(topic)))) {
|
|
80
80
|
throw new Error(`topics in header.topics must be formatted keccak256 hashes`);
|
|
81
81
|
}
|
|
82
82
|
return maybeBlock;
|
|
@@ -96,7 +96,7 @@ function pushTransaction(block, transaction, channelId, topics = []) {
|
|
|
96
96
|
throw new Error('The transaction is missing the data property or encryptedData property');
|
|
97
97
|
}
|
|
98
98
|
// we don't want to modify the original block state
|
|
99
|
-
const copiedBlock = utils_1.
|
|
99
|
+
const copiedBlock = (0, utils_1.deepCopy)(block);
|
|
100
100
|
const newTransactionPosition = copiedBlock.transactions.length;
|
|
101
101
|
copiedBlock.transactions.push(transaction);
|
|
102
102
|
// index the transaction with the channel id
|
|
@@ -132,8 +132,8 @@ function getTransactionsByPositions(block, positions) {
|
|
|
132
132
|
// remove duplicates and sort
|
|
133
133
|
const sortedPositions = Array.from(new Set(positions)).sort();
|
|
134
134
|
return sortedPositions
|
|
135
|
-
.map(position => block.transactions[position])
|
|
136
|
-
.filter(position => position !== undefined);
|
|
135
|
+
.map((position) => block.transactions[position])
|
|
136
|
+
.filter((position) => position !== undefined);
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* Returns all transactions of a block
|
|
@@ -166,8 +166,8 @@ function getTransactionPositionFromChannelId(block, channelId) {
|
|
|
166
166
|
*/
|
|
167
167
|
function getTransactionPositionsByChannelIds(block, channelIds) {
|
|
168
168
|
const result = channelIds
|
|
169
|
-
.map(id => block.header.channelIds[id])
|
|
170
|
-
.filter(value => value !== undefined)
|
|
169
|
+
.map((id) => block.header.channelIds[id])
|
|
170
|
+
.filter((value) => value !== undefined)
|
|
171
171
|
.reduce((accumulator, current) => accumulator.concat(current), []);
|
|
172
172
|
// remove duplicates and sort
|
|
173
173
|
return Array.from(new Set(result)).sort();
|
package/dist/block.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.js","sourceRoot":"","sources":["../src/block.ts"],"names":[],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"block.js","sourceRoot":"","sources":["../src/block.ts"],"names":[],"mappings":";;AAAA,4DAA4D;AAE5D,iDAAiD;AAEjD;;;GAGG;AACH,kBAAe;IACb,gBAAgB;IAChB,gBAAgB;IAChB,YAAY;IACZ,kBAAkB;IAClB,0BAA0B;IAC1B,mCAAmC;IACnC,mCAAmC;IACnC,0BAA0B;IAC1B,UAAU;IACV,eAAe;CAChB,CAAC;AAEF;;;;GAIG;AACH,SAAS,gBAAgB;IACvB,OAAO;QACL,MAAM,EAAE;YACN,UAAU,EAAE,EAAE;YACd,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,OAAO;SACjB;QACD,YAAY,EAAE,EAAE;KACjB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,UAAU,CAAC,IAAY;IAC9B,IAA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1C,KAA6B,EAC7B,SAAiB;IAEjB,OAAO,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;AAClD,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,mCAAmC,CAC1C,KAA6B,EAC7B,UAAoB;IAEpB,MAAM,MAAM,GAAa,UAAU;SAChC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;SACxC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC;SACtC,MAAM,CAAC,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IAErE,6BAA6B;IAC7B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC5C,CAAC;AAED;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,KAA6B;IACjD,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;AAC7B,CAAC;AAED;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,KAA6B;IACrD,OAAO,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DataAccessTypes } from '@requestnetwork/types';
|
|
2
|
+
export declare abstract class CombinedDataAccess implements DataAccessTypes.IDataAccess {
|
|
3
|
+
protected reader: DataAccessTypes.IDataRead;
|
|
4
|
+
protected writer: DataAccessTypes.IDataWrite;
|
|
5
|
+
constructor(reader: DataAccessTypes.IDataRead, writer: DataAccessTypes.IDataWrite);
|
|
6
|
+
initialize(): Promise<void>;
|
|
7
|
+
close(): Promise<void>;
|
|
8
|
+
getTransactionsByChannelId(channelId: string, updatedBetween?: DataAccessTypes.ITimestampBoundaries | undefined): Promise<DataAccessTypes.IReturnGetTransactions>;
|
|
9
|
+
getChannelsByTopic(topic: string, updatedBetween?: DataAccessTypes.ITimestampBoundaries | undefined): Promise<DataAccessTypes.IReturnGetChannelsByTopic>;
|
|
10
|
+
getChannelsByMultipleTopics(topics: string[], updatedBetween?: DataAccessTypes.ITimestampBoundaries): Promise<DataAccessTypes.IReturnGetChannelsByTopic>;
|
|
11
|
+
persistTransaction(transactionData: DataAccessTypes.ITransaction, channelId: string, topics?: string[] | undefined): Promise<DataAccessTypes.IReturnPersistTransaction>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=combined-data-access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combined-data-access.d.ts","sourceRoot":"","sources":["../src/combined-data-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,8BAAsB,kBAAmB,YAAW,eAAe,CAAC,WAAW;IAE3E,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC,SAAS;IAC3C,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC,UAAU;gBADlC,MAAM,EAAE,eAAe,CAAC,SAAS,EACjC,MAAM,EAAE,eAAe,CAAC,UAAU;IAGxC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAKtB,0BAA0B,CAC9B,SAAS,EAAE,MAAM,EACjB,cAAc,CAAC,EAAE,eAAe,CAAC,oBAAoB,GAAG,SAAS,GAChE,OAAO,CAAC,eAAe,CAAC,sBAAsB,CAAC;IAI5C,kBAAkB,CACtB,KAAK,EAAE,MAAM,EACb,cAAc,CAAC,EAAE,eAAe,CAAC,oBAAoB,GAAG,SAAS,GAChE,OAAO,CAAC,eAAe,CAAC,yBAAyB,CAAC;IAG/C,2BAA2B,CAC/B,MAAM,EAAE,MAAM,EAAE,EAChB,cAAc,CAAC,EAAE,eAAe,CAAC,oBAAoB,GACpD,OAAO,CAAC,eAAe,CAAC,yBAAyB,CAAC;IAG/C,kBAAkB,CACtB,eAAe,EAAE,eAAe,CAAC,YAAY,EAC7C,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,GAC5B,OAAO,CAAC,eAAe,CAAC,yBAAyB,CAAC;CAGtD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CombinedDataAccess = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
class CombinedDataAccess {
|
|
6
|
+
constructor(reader, writer) {
|
|
7
|
+
this.reader = reader;
|
|
8
|
+
this.writer = writer;
|
|
9
|
+
}
|
|
10
|
+
initialize() {
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
yield this.reader.initialize();
|
|
13
|
+
yield this.writer.initialize();
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
close() {
|
|
17
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
yield this.writer.close();
|
|
19
|
+
yield this.reader.close();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
getTransactionsByChannelId(channelId, updatedBetween) {
|
|
23
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return yield this.reader.getTransactionsByChannelId(channelId, updatedBetween);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
getChannelsByTopic(topic, updatedBetween) {
|
|
28
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
return yield this.reader.getChannelsByTopic(topic, updatedBetween);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
getChannelsByMultipleTopics(topics, updatedBetween) {
|
|
33
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return yield this.reader.getChannelsByMultipleTopics(topics, updatedBetween);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
persistTransaction(transactionData, channelId, topics) {
|
|
38
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
return yield this.writer.persistTransaction(transactionData, channelId, topics);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.CombinedDataAccess = CombinedDataAccess;
|
|
44
|
+
//# sourceMappingURL=combined-data-access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combined-data-access.js","sourceRoot":"","sources":["../src/combined-data-access.ts"],"names":[],"mappings":";;;;AAEA,MAAsB,kBAAkB;IACtC,YACY,MAAiC,EACjC,MAAkC;QADlC,WAAM,GAAN,MAAM,CAA2B;QACjC,WAAM,GAAN,MAAM,CAA4B;IAC3C,CAAC;IAEE,UAAU;;YACd,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YAC/B,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACjC,CAAC;KAAA;IAEK,KAAK;;YACT,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAC1B,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC5B,CAAC;KAAA;IAEK,0BAA0B,CAC9B,SAAiB,EACjB,cAAiE;;YAEjE,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QACjF,CAAC;KAAA;IAEK,kBAAkB,CACtB,KAAa,EACb,cAAiE;;YAEjE,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QACrE,CAAC;KAAA;IACK,2BAA2B,CAC/B,MAAgB,EAChB,cAAqD;;YAErD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QAC/E,CAAC;KAAA;IACK,kBAAkB,CACtB,eAA6C,EAC7C,SAAiB,EACjB,MAA6B;;YAE7B,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,eAAe,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAClF,CAAC;KAAA;CACF;AA1CD,gDA0CC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DataAccessTypes, StorageTypes } from '@requestnetwork/types';
|
|
2
|
+
import { DataAccessBaseOptions } from './types';
|
|
3
|
+
export declare class DataAccessRead implements DataAccessTypes.IDataRead {
|
|
4
|
+
private readonly storage;
|
|
5
|
+
private network;
|
|
6
|
+
private pendingStore?;
|
|
7
|
+
constructor(storage: StorageTypes.IIndexer, { network, pendingStore }: DataAccessBaseOptions);
|
|
8
|
+
initialize(): Promise<void>;
|
|
9
|
+
close(): Promise<void>;
|
|
10
|
+
getTransactionsByChannelId(channelId: string, updatedBetween?: DataAccessTypes.ITimestampBoundaries): Promise<DataAccessTypes.IReturnGetTransactions>;
|
|
11
|
+
getChannelsByTopic(topic: string, updatedBetween?: DataAccessTypes.ITimestampBoundaries | undefined): Promise<DataAccessTypes.IReturnGetChannelsByTopic>;
|
|
12
|
+
getChannelsByMultipleTopics(topics: string[], updatedBetween?: DataAccessTypes.ITimestampBoundaries): Promise<DataAccessTypes.IReturnGetChannelsByTopic>;
|
|
13
|
+
private getPending;
|
|
14
|
+
protected toStorageMeta(result: StorageTypes.IIndexedTransaction, lastBlockNumber: number, network: string): StorageTypes.IEntryMetadata;
|
|
15
|
+
protected toTimestampedTransaction(transaction: StorageTypes.IIndexedTransaction): DataAccessTypes.ITimestampedTransaction;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=data-read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-read.d.ts","sourceRoot":"","sources":["../src/data-read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,E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5
|
+
const types_1 = require("@requestnetwork/types");
|
|
6
|
+
class DataAccessRead {
|
|
7
|
+
constructor(storage, { network, pendingStore }) {
|
|
8
|
+
this.storage = storage;
|
|
9
|
+
this.network = network;
|
|
10
|
+
this.pendingStore = pendingStore;
|
|
11
|
+
}
|
|
12
|
+
initialize() {
|
|
13
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
yield this.storage.initialize();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
close() {
|
|
18
|
+
return Promise.resolve();
|
|
19
|
+
}
|
|
20
|
+
getTransactionsByChannelId(channelId, updatedBetween) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const pending = yield this.getPending(channelId);
|
|
23
|
+
const result = yield this.storage.getTransactionsByChannelId(channelId, updatedBetween);
|
|
24
|
+
return {
|
|
25
|
+
meta: {
|
|
26
|
+
transactionsStorageLocation: result.transactions
|
|
27
|
+
.map((x) => x.hash)
|
|
28
|
+
.concat(pending.meta.transactionsStorageLocation),
|
|
29
|
+
storageMeta: result.transactions.map((tx) => this.toStorageMeta(tx, result.blockNumber, this.network)),
|
|
30
|
+
},
|
|
31
|
+
result: {
|
|
32
|
+
transactions: result.transactions
|
|
33
|
+
.map(this.toTimestampedTransaction)
|
|
34
|
+
.concat(pending.result.transactions),
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
getChannelsByTopic(topic, updatedBetween) {
|
|
40
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return this.getChannelsByMultipleTopics([topic], updatedBetween);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
getChannelsByMultipleTopics(topics, updatedBetween) {
|
|
45
|
+
var _a;
|
|
46
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const result = yield this.storage.getTransactionsByTopics(topics);
|
|
48
|
+
const pending = ((_a = this.pendingStore) === null || _a === void 0 ? void 0 : _a.findByTopics(topics)) || [];
|
|
49
|
+
const pendingItems = pending.map((item) => {
|
|
50
|
+
var _a, _b, _c, _d, _e;
|
|
51
|
+
return (Object.assign(Object.assign({ hash: item.storageResult.id, channelId: item.channelId }, item.transaction), { blockNumber: ((_a = item.storageResult.meta.ethereum) === null || _a === void 0 ? void 0 : _a.blockNumber) || -1, blockTimestamp: ((_b = item.storageResult.meta.ethereum) === null || _b === void 0 ? void 0 : _b.blockTimestamp) || -1, transactionHash: ((_c = item.storageResult.meta.ethereum) === null || _c === void 0 ? void 0 : _c.transactionHash) || '', smartContractAddress: ((_d = item.storageResult.meta.ethereum) === null || _d === void 0 ? void 0 : _d.smartContractAddress) || '', size: String(((_e = item.storageResult.meta.ipfs) === null || _e === void 0 ? void 0 : _e.size) || 0), topics: item.topics || [] }));
|
|
52
|
+
});
|
|
53
|
+
const transactions = result.transactions.concat(...pendingItems);
|
|
54
|
+
// list of channels having at least one tx updated during the updatedBetween boundaries
|
|
55
|
+
const channels = (updatedBetween
|
|
56
|
+
? transactions.filter((tx) => tx.blockTimestamp >= (updatedBetween.from || 0) &&
|
|
57
|
+
tx.blockTimestamp <= (updatedBetween.to || Number.MAX_SAFE_INTEGER))
|
|
58
|
+
: transactions).map((x) => x.channelId);
|
|
59
|
+
const filteredTxs = transactions.filter((tx) => channels.includes(tx.channelId));
|
|
60
|
+
return {
|
|
61
|
+
meta: {
|
|
62
|
+
storageMeta: filteredTxs.reduce((acc, tx) => {
|
|
63
|
+
acc[tx.channelId] = [this.toStorageMeta(tx, result.blockNumber, this.network)];
|
|
64
|
+
return acc;
|
|
65
|
+
}, {}),
|
|
66
|
+
transactionsStorageLocation: filteredTxs.reduce((prev, curr) => {
|
|
67
|
+
if (!prev[curr.channelId]) {
|
|
68
|
+
prev[curr.channelId] = [];
|
|
69
|
+
}
|
|
70
|
+
prev[curr.channelId].push(curr.hash);
|
|
71
|
+
return prev;
|
|
72
|
+
}, {}),
|
|
73
|
+
},
|
|
74
|
+
result: {
|
|
75
|
+
transactions: filteredTxs.reduce((prev, curr) => {
|
|
76
|
+
if (!prev[curr.channelId]) {
|
|
77
|
+
prev[curr.channelId] = [];
|
|
78
|
+
}
|
|
79
|
+
prev[curr.channelId].push(this.toTimestampedTransaction(curr));
|
|
80
|
+
return prev;
|
|
81
|
+
}, {}),
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
getPending(channelId) {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const emptyResult = {
|
|
90
|
+
meta: {
|
|
91
|
+
transactionsStorageLocation: [],
|
|
92
|
+
storageMeta: [],
|
|
93
|
+
},
|
|
94
|
+
result: {
|
|
95
|
+
transactions: [],
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
const pending = (_a = this.pendingStore) === null || _a === void 0 ? void 0 : _a.get(channelId);
|
|
99
|
+
if (!pending) {
|
|
100
|
+
return emptyResult;
|
|
101
|
+
}
|
|
102
|
+
const { storageResult, transaction } = pending;
|
|
103
|
+
const { transactions } = yield this.storage.getTransactionsByStorageLocation(storageResult.id);
|
|
104
|
+
// if the pending tx is found, remove its state and fetch the real data
|
|
105
|
+
if (transactions.length > 0) {
|
|
106
|
+
(_b = this.pendingStore) === null || _b === void 0 ? void 0 : _b.remove(channelId);
|
|
107
|
+
return emptyResult;
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
meta: {
|
|
111
|
+
transactionsStorageLocation: [storageResult.id],
|
|
112
|
+
storageMeta: [storageResult.meta],
|
|
113
|
+
},
|
|
114
|
+
result: {
|
|
115
|
+
transactions: [
|
|
116
|
+
{
|
|
117
|
+
state: types_1.DataAccessTypes.TransactionState.PENDING,
|
|
118
|
+
timestamp: storageResult.meta.timestamp,
|
|
119
|
+
transaction,
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
toStorageMeta(result, lastBlockNumber, network) {
|
|
127
|
+
return {
|
|
128
|
+
ethereum: {
|
|
129
|
+
blockConfirmation: lastBlockNumber - result.blockNumber,
|
|
130
|
+
blockNumber: result.blockNumber,
|
|
131
|
+
blockTimestamp: result.blockTimestamp,
|
|
132
|
+
networkName: network,
|
|
133
|
+
smartContractAddress: result.smartContractAddress,
|
|
134
|
+
transactionHash: result.transactionHash,
|
|
135
|
+
},
|
|
136
|
+
ipfs: {
|
|
137
|
+
size: parseInt(result.size),
|
|
138
|
+
},
|
|
139
|
+
state: types_1.StorageTypes.ContentState.CONFIRMED,
|
|
140
|
+
storageType: types_1.StorageTypes.StorageSystemType.ETHEREUM_IPFS,
|
|
141
|
+
timestamp: result.blockTimestamp,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
toTimestampedTransaction(transaction) {
|
|
145
|
+
return {
|
|
146
|
+
state: types_1.DataAccessTypes.TransactionState.CONFIRMED,
|
|
147
|
+
timestamp: transaction.blockTimestamp,
|
|
148
|
+
transaction: {
|
|
149
|
+
data: transaction.data || undefined,
|
|
150
|
+
encryptedData: transaction.encryptedData || undefined,
|
|
151
|
+
encryptionMethod: transaction.encryptionMethod || undefined,
|
|
152
|
+
keys: transaction.keys || undefined,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.DataAccessRead = DataAccessRead;
|
|
158
|
+
//# sourceMappingURL=data-read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-read.js","sourceRoot":"","sources":["../src/data-read.ts"],"names":[],"mappings":";;;;AAAA,iDAAsE;AAGtE,MAAa,cAAc;IAKzB,YACmB,OAA8B,EAC/C,EAAE,OAAO,EAAE,YAAY,EAAyB;QAD/B,YAAO,GAAP,OAAO,CAAuB;QAG/C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACv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xC,eAAuB,EACvB,OAAe;QAEf,OAAO;YACL,QAAQ,EAAE;gBACR,iBAAiB,EAAE,eAAe,GAAG,MAAM,CAAC,WAAW;gBACvD,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,cAAc,EAAE,MAAM,CAAC,cAAc;gBACrC,WAAW,EAAE,OAAO;gBACpB,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;gBACjD,eAAe,EAAE,MAAM,CAAC,eAAe;aACxC;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;aAC5B;YACD,KAAK,EAAE,oBAAY,CAAC,YAAY,CAAC,SAAS;YAC1C,WAAW,EAAE,oBAAY,CAAC,iBAAiB,CAAC,aAAa;YACzD,SAAS,EAAE,MAAM,CAAC,cAAc;SACjC,CAAC;IACJ,CAAC;IAES,wBAAwB,CAChC,WAA6C;QAE7C,OAAO;YACL,KAAK,EAAE,uBAAe,CAAC,gBAAgB,CAAC,SAAS;YACjD,SAAS,EAAE,WAAW,CAAC,cAAc;YACrC,WAAW,EAAE;gBACX,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,SAAS;gBACnC,aAAa,EAAE,WAAW,CAAC,aAAa,IAAI,SAAS;gBACrD,gBAAgB,EAAE,WAAW,CAAC,gBAAgB,IAAI,SAAS;gBAC3D,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,SAAS;aACpC;SACF,CAAC;IACJ,CAAC;CACF;AApMD,wCAoMC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DataAccessTypes, StorageTypes } from '@requestnetwork/types';
|
|
2
|
+
export declare class DataAccessWrite implements DataAccessTypes.IDataWrite {
|
|
3
|
+
protected readonly storage: StorageTypes.IStorageWrite;
|
|
4
|
+
private readonly pendingStore?;
|
|
5
|
+
constructor(storage: StorageTypes.IStorageWrite, pendingStore?: DataAccessTypes.IPendingStore | undefined);
|
|
6
|
+
initialize(): Promise<void>;
|
|
7
|
+
close(): Promise<void>;
|
|
8
|
+
persistTransaction(transaction: DataAccessTypes.ITransaction, channelId: string, topics?: string[] | undefined): Promise<DataAccessTypes.IReturnPersistTransaction>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=data-write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-write.d.ts","sourceRoot":"","sources":["../src/data-write.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEtE,qBAAa,eAAgB,YAAW,eAAe,CAAC,UAAU;IAE9D,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,aAAa;IACtD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;gBADX,OAAO,EAAE,YAAY,CAAC,aAAa,EACrC,YAAY,CAAC,2CAA+B;IAKzD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,kBAAkB,CACtB,WAAW,EAAE,eAAe,CAAC,YAAY,EACzC,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,GAC5B,OAAO,CAAC,eAAe,CAAC,yBAAyB,CAAC;CA6BtD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataAccessWrite = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const events_1 = require("events");
|
|
6
|
+
const block_1 = require("./block");
|
|
7
|
+
class DataAccessWrite {
|
|
8
|
+
constructor(storage, pendingStore) {
|
|
9
|
+
this.storage = storage;
|
|
10
|
+
this.pendingStore = pendingStore;
|
|
11
|
+
this.pendingStore = pendingStore;
|
|
12
|
+
}
|
|
13
|
+
initialize() {
|
|
14
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
return;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
close() {
|
|
19
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
return;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
persistTransaction(transaction, channelId, topics) {
|
|
24
|
+
var _a;
|
|
25
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const updatedBlock = block_1.default.pushTransaction(block_1.default.createEmptyBlock(), transaction, channelId, topics);
|
|
27
|
+
const storageResult = yield this.storage.append(JSON.stringify(updatedBlock));
|
|
28
|
+
const eventEmitter = new events_1.EventEmitter();
|
|
29
|
+
(_a = this.pendingStore) === null || _a === void 0 ? void 0 : _a.add(channelId, { transaction, storageResult, topics: topics || [] });
|
|
30
|
+
const result = {
|
|
31
|
+
meta: {
|
|
32
|
+
transactionStorageLocation: storageResult.id,
|
|
33
|
+
storageMeta: storageResult.meta,
|
|
34
|
+
topics: topics || [],
|
|
35
|
+
},
|
|
36
|
+
result: {},
|
|
37
|
+
};
|
|
38
|
+
storageResult.on('confirmed', (r) => {
|
|
39
|
+
result.meta.storageMeta = r.meta;
|
|
40
|
+
eventEmitter.emit('confirmed', result);
|
|
41
|
+
});
|
|
42
|
+
storageResult.on('error', (err) => eventEmitter.emit('error', err));
|
|
43
|
+
return Object.assign(eventEmitter, result);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.DataAccessWrite = DataAccessWrite;
|
|
48
|
+
//# sourceMappingURL=data-write.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-write.js","sourceRoot":"","sources":["../src/data-write.ts"],"names":[],"mappings":";;;;AAAA,mCAAsC;AACtC,mCAA4B;AAG5B,MAAa,eAAe;IAC1B,YACqB,OAAmC,EACrC,YAA4C;QAD1C,YAAO,GAAP,OAAO,CAA4B;QACrC,iBAAY,GAAZ,YAAY,CAAgC;QAE7D,IAAI,CAAC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ACF;AAjDD,0CAiDC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StorageTypes } from '@requestnetwork/types';
|
|
2
|
+
/**
|
|
3
|
+
* InMemory implementation to index Request storage transactions, for testing and development.
|
|
4
|
+
* The data itself is not indexed, only references to its location
|
|
5
|
+
*/
|
|
6
|
+
export declare class InMemoryIndexer implements StorageTypes.IIndexer {
|
|
7
|
+
#private;
|
|
8
|
+
private readonly storageRead;
|
|
9
|
+
constructor(storageRead: StorageTypes.IStorageRead);
|
|
10
|
+
/** Adds the indexed data for easy retrieval */
|
|
11
|
+
addIndex(channelId: string, topics: string[], location: string): void;
|
|
12
|
+
initialize(): Promise<void>;
|
|
13
|
+
getTransactionsByStorageLocation(hash: string): Promise<StorageTypes.IGetTransactionsResponse>;
|
|
14
|
+
getTransactionsByChannelId(channelId: string): Promise<StorageTypes.IGetTransactionsResponse>;
|
|
15
|
+
getTransactionsByTopics(topics: string[]): Promise<StorageTypes.IGetTransactionsResponse>;
|
|
16
|
+
private parseDocuments;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=in-memory-indexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory-indexer.d.ts","sourceRoot":"","sources":["../src/in-memory-indexer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAarD;;;GAGG;AACH,qBAAa,eAAgB,YAAW,YAAY,CAAC,QAAQ;;IAK/C,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,YAAY,CAAC,YAAY;IAEnE,+CAA+C;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAOtE,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,gCAAgC,CACpC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,CAAC,wBAAwB,CAAC;IAQ3C,0BAA0B,CAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,YAAY,CAAC,wBAAwB,CAAC;IAS3C,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,wBAAwB,CAAC;YAcjF,cAAc;CAgC7B"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _InMemoryIndexer_channelToLocationsIndex, _InMemoryIndexer_topicToChannelsIndex;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.InMemoryIndexer = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const types_1 = require("@requestnetwork/types");
|
|
7
|
+
const block_1 = require("./block");
|
|
8
|
+
/** Helper class to manage a map with arrays as values */
|
|
9
|
+
class ArrayMap extends Map {
|
|
10
|
+
add(key, value) {
|
|
11
|
+
return this.set(key, this.get(key).concat(value));
|
|
12
|
+
}
|
|
13
|
+
get(key) {
|
|
14
|
+
return super.get(key) || [];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* InMemory implementation to index Request storage transactions, for testing and development.
|
|
19
|
+
* The data itself is not indexed, only references to its location
|
|
20
|
+
*/
|
|
21
|
+
class InMemoryIndexer {
|
|
22
|
+
constructor(storageRead) {
|
|
23
|
+
this.storageRead = storageRead;
|
|
24
|
+
// these fields must be private (#) or jest's matcher won't work.
|
|
25
|
+
_InMemoryIndexer_channelToLocationsIndex.set(this, new ArrayMap());
|
|
26
|
+
_InMemoryIndexer_topicToChannelsIndex.set(this, new ArrayMap());
|
|
27
|
+
}
|
|
28
|
+
/** Adds the indexed data for easy retrieval */
|
|
29
|
+
addIndex(channelId, topics, location) {
|
|
30
|
+
tslib_1.__classPrivateFieldGet(this, _InMemoryIndexer_channelToLocationsIndex, "f").add(channelId, location);
|
|
31
|
+
for (const topic of topics || []) {
|
|
32
|
+
tslib_1.__classPrivateFieldGet(this, _InMemoryIndexer_topicToChannelsIndex, "f").add(topic, channelId);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
initialize() {
|
|
36
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
return;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
getTransactionsByStorageLocation(hash) {
|
|
41
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const transactions = yield this.parseDocuments([hash]);
|
|
43
|
+
return {
|
|
44
|
+
blockNumber: 0,
|
|
45
|
+
transactions,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
getTransactionsByChannelId(channelId) {
|
|
50
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const locations = tslib_1.__classPrivateFieldGet(this, _InMemoryIndexer_channelToLocationsIndex, "f").get(channelId);
|
|
52
|
+
const transactions = yield this.parseDocuments(locations);
|
|
53
|
+
return {
|
|
54
|
+
blockNumber: 0,
|
|
55
|
+
transactions: transactions.filter((x) => x.channelId === channelId),
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
getTransactionsByTopics(topics) {
|
|
60
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const channelIds = topics.map((topic) => tslib_1.__classPrivateFieldGet(this, _InMemoryIndexer_topicToChannelsIndex, "f").get(topic)).flat();
|
|
62
|
+
const locations = channelIds
|
|
63
|
+
.map((channel) => tslib_1.__classPrivateFieldGet(this, _InMemoryIndexer_channelToLocationsIndex, "f").get(channel))
|
|
64
|
+
.flat();
|
|
65
|
+
const transactions = yield this.parseDocuments(locations);
|
|
66
|
+
return {
|
|
67
|
+
blockNumber: 0,
|
|
68
|
+
transactions,
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
parseDocuments(locations) {
|
|
73
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const entries = yield this.storageRead.readMany(locations);
|
|
75
|
+
return entries
|
|
76
|
+
.filter((x) => x.meta.state === types_1.StorageTypes.ContentState.CONFIRMED)
|
|
77
|
+
.map((curr) => {
|
|
78
|
+
const { id, meta, content } = curr;
|
|
79
|
+
const block = block_1.default.parseBlock(content);
|
|
80
|
+
return Object.entries(block.header.channelIds).map(([channelId, [index]]) => ({
|
|
81
|
+
locationId: id,
|
|
82
|
+
channelId,
|
|
83
|
+
meta,
|
|
84
|
+
transaction: block.transactions[index],
|
|
85
|
+
}));
|
|
86
|
+
})
|
|
87
|
+
.flat()
|
|
88
|
+
.map((item) => {
|
|
89
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
90
|
+
return ({
|
|
91
|
+
blockNumber: (_b = (_a = item.meta.ethereum) === null || _a === void 0 ? void 0 : _a.blockNumber) !== null && _b !== void 0 ? _b : 0,
|
|
92
|
+
blockTimestamp: (_d = (_c = item.meta.ethereum) === null || _c === void 0 ? void 0 : _c.blockTimestamp) !== null && _d !== void 0 ? _d : 0,
|
|
93
|
+
channelId: item.channelId,
|
|
94
|
+
hash: item.locationId,
|
|
95
|
+
size: String((_f = (_e = item.meta.ipfs) === null || _e === void 0 ? void 0 : _e.size) !== null && _f !== void 0 ? _f : 0),
|
|
96
|
+
smartContractAddress: (_h = (_g = item.meta.ethereum) === null || _g === void 0 ? void 0 : _g.smartContractAddress) !== null && _h !== void 0 ? _h : '',
|
|
97
|
+
topics: [],
|
|
98
|
+
transactionHash: (_k = (_j = item.meta.ethereum) === null || _j === void 0 ? void 0 : _j.transactionHash) !== null && _k !== void 0 ? _k : '',
|
|
99
|
+
data: item.transaction.data,
|
|
100
|
+
encryptedData: item.transaction.encryptedData,
|
|
101
|
+
encryptionMethod: item.transaction.encryptionMethod,
|
|
102
|
+
keys: item.transaction.keys,
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.InMemoryIndexer = InMemoryIndexer;
|
|
109
|
+
_InMemoryIndexer_channelToLocationsIndex = new WeakMap(), _InMemoryIndexer_topicToChannelsIndex = new WeakMap();
|
|
110
|
+
//# sourceMappingURL=in-memory-indexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory-indexer.js","sourceRoot":"","sources":["../src/in-memory-indexer.ts"],"names":[],"mappings":";;;;;AAAA,iDAAqD;AACrD,mCAA4B;AAE5B,yDAAyD;AACzD,MAAM,QAAY,SAAQ,GAAgB;IACxC,GAAG,CAAC,GAAW,EAAE,KAAQ;QACvB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACpD,CAAC;IACD,GAAG,CAAC,GAAW;QACb,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;CACF;AAED;;;GAGG;AACH,MAAa,eAAe;IAK1B,YAA6B,WAAsC;QAAtC,gBAAW,GAAX,WAAW,CAA2B;QAJnE,iEAAiE;QACxD,mDAA2B,IAAI,QAAQ,EAAU,EAAC;QAClD,gDAAwB,IAAI,QAAQ,EAAU,EAAC;IAEc,CAAC;IAEvE,+CAA+C;IACxC,QAAQ,CAAC,SAAiB,EAAE,MAAgB,EAAE,QAAgB;QACnE,+BAAA,IAAI,gDAAyB,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QACvD,KAAK,MAAM,KAAK,IAAI,MAAM,IAAI,EAAE,EAAE;YAChC,+BAAA,IAAI,6CAAsB,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;SAClD;IACH,CAAC;IAEK,UAAU;;YACd,OAAO;QACT,CAAC;KAAA;IAEK,gCAAgC,CACpC,IAAY;;YAEZ,MAAM,YAAY,GAAG,MAAM,IA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AAI,CAAC,WAAW,CAAC,aAAa;oBAC7C,gBAAgB,EAAE,IAAI,CAAC,WAAW,CAAC,gBAAgB;oBACnD,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;iBAC5B,CAAC,CAAA;aAAA,CACH,CAAC;QACN,CAAC;KAAA;CACF;AAtFD,0CAsFC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export { default as DataAccess } from './data-access';
|
|
2
|
-
export { default as TransactionIndex } from './transaction-index';
|
|
3
1
|
export { default as Block } from './block';
|
|
2
|
+
export { CombinedDataAccess } from './combined-data-access';
|
|
3
|
+
export { DataAccessWrite } from './data-write';
|
|
4
|
+
export { DataAccessRead } from './data-read';
|
|
5
|
+
export { PendingStore } from './pending-store';
|
|
6
|
+
export { DataAccessBaseOptions } from './types';
|
|
7
|
+
export { MockDataAccess } from './mock-data-access';
|
|
4
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|