@requestnetwork/data-access
Advanced tools
Comparing version 0.7.1-next.1206 to 0.7.1-next.1207
@@ -107,3 +107,4 @@ "use strict"; | ||
// Store the data to the real storage | ||
resultAppend.on('confirmed', (resultAppendConfirmed) => { | ||
resultAppend | ||
.on('confirmed', (resultAppendConfirmed) => { | ||
// update the timestamp with the confirmed one | ||
@@ -120,3 +121,7 @@ this.transactionIndex.updateTimestamp(resultAppendConfirmed.id, resultAppendConfirmed.meta.timestamp); | ||
result.emit('confirmed', resultAfterConfirmation); | ||
}); | ||
}) | ||
.on('error', (error) => __awaiter(this, void 0, void 0, function* () { | ||
yield this.transactionIndex.removeTransaction(resultAppend.id); | ||
result.emit('error', error); | ||
})); | ||
// adds this transaction to the index, to enable retrieving it later. | ||
@@ -123,0 +128,0 @@ yield this.transactionIndex.addTransaction(resultAppend.id, updatedBlock.header, resultAppend.meta.timestamp); |
@@ -25,2 +25,8 @@ import { DataAccessTypes } from '@requestnetwork/types'; | ||
/** | ||
* Removes timestamp indexed by location | ||
* | ||
* @param dataId dataId of the block | ||
*/ | ||
removeIndexedDataId(dataId: string): Promise<void>; | ||
/** | ||
* Function to update timestamp indexed by location | ||
@@ -27,0 +33,0 @@ * |
@@ -45,2 +45,12 @@ "use strict"; | ||
/** | ||
* Removes timestamp indexed by location | ||
* | ||
* @param dataId dataId of the block | ||
*/ | ||
removeIndexedDataId(dataId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.timestampByLocation.delete(dataId); | ||
}); | ||
} | ||
/** | ||
* Function to update timestamp indexed by location | ||
@@ -69,3 +79,3 @@ * | ||
const timestamp = yield this.timestampByLocation.get(dataId); | ||
return timestamp ? timestamp : null; | ||
return timestamp !== undefined ? timestamp : null; | ||
}); | ||
@@ -72,0 +82,0 @@ } |
@@ -28,2 +28,8 @@ import { DataAccessTypes } from '@requestnetwork/types'; | ||
/** | ||
* Removes a transaction from the index | ||
* | ||
* @param dataId the dataId to remove | ||
*/ | ||
removeTransaction(dataId: string): Promise<void>; | ||
/** | ||
* Update timestamp for a dataId | ||
@@ -30,0 +36,0 @@ * |
@@ -56,2 +56,16 @@ "use strict"; | ||
/** | ||
* Removes a transaction from the index | ||
* | ||
* @param dataId the dataId to remove | ||
*/ | ||
removeTransaction(dataId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.locationByTopic) { | ||
throw new Error('TransactionIndex must be initialized'); | ||
} | ||
// remove the timestamp in the index | ||
yield this.timestampByLocation.removeIndexedDataId(dataId); | ||
}); | ||
} | ||
/** | ||
* Update timestamp for a dataId | ||
@@ -84,6 +98,10 @@ * | ||
let storageLocationList = yield this.locationByTopic.getStorageLocationsFromChannelId(channelId); | ||
// if boundaries are passed, only return locations of transaction within these boundaries | ||
if (timestampBoundaries) { | ||
storageLocationList = yield Bluebird.filter(storageLocationList, (dataId) => this.timestampByLocation.isDataInBoundaries(dataId, timestampBoundaries)); | ||
} | ||
storageLocationList = yield Bluebird.filter(storageLocationList, (dataId) => __awaiter(this, void 0, void 0, function* () { | ||
// if the dataId has not been suppressed | ||
const exist = (yield this.timestampByLocation.getTimestampFromLocation(dataId)) !== null; | ||
// if boundaries are passed, only return locations of transaction within these boundaries | ||
const inTimeBoundaries = !timestampBoundaries || | ||
(yield this.timestampByLocation.isDataInBoundaries(dataId, timestampBoundaries)); | ||
return exist && inTimeBoundaries; | ||
})); | ||
return storageLocationList; | ||
@@ -90,0 +108,0 @@ }); |
{ | ||
"name": "@requestnetwork/data-access", | ||
"version": "0.7.1-next.1206+0e5e6765", | ||
"version": "0.7.1-next.1207+73bfcfb5", | ||
"publishConfig": { | ||
@@ -43,5 +43,5 @@ "access": "public" | ||
"dependencies": { | ||
"@requestnetwork/multi-format": "0.2.7-next.1206+0e5e6765", | ||
"@requestnetwork/types": "0.13.1-next.1206+0e5e6765", | ||
"@requestnetwork/utils": "0.12.1-next.1206+0e5e6765", | ||
"@requestnetwork/multi-format": "0.2.7-next.1207+73bfcfb5", | ||
"@requestnetwork/types": "0.13.1-next.1207+73bfcfb5", | ||
"@requestnetwork/utils": "0.12.1-next.1207+73bfcfb5", | ||
"bluebird": "3.5.5", | ||
@@ -81,3 +81,3 @@ "keyv": "3.1.0" | ||
}, | ||
"gitHead": "0e5e67658bec6579157afc09f28b2bc5a7f027e6" | ||
"gitHead": "73bfcfb5f6a54d2036a47e09ce180a00c12a81ae" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
125641
1517