@totemsdk/wots-lease 0.1.4 → 0.1.5
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/dist/local.js +2 -1
- package/package.json +1 -1
package/dist/local.js
CHANGED
|
@@ -87,13 +87,14 @@ class LocalLeaseProvider {
|
|
|
87
87
|
const ttlMs = params.ttlMs ?? 120000;
|
|
88
88
|
// Atomically get the next available index AND mark it reserved in the watermark
|
|
89
89
|
const indices = this.watermark.getNextIndices(treeId);
|
|
90
|
-
|
|
90
|
+
// Validate device range BEFORE marking unavailable — prevents permanent index loss
|
|
91
91
|
if (params.deviceId) {
|
|
92
92
|
const range = this.getDeviceRange(params.deviceId);
|
|
93
93
|
if (range && (indices.addressIndex < range.start || indices.addressIndex > range.end)) {
|
|
94
94
|
throw new errors_js_1.DeviceRangeViolationError(indices.addressIndex, range.start, range.end);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
await this.watermark.markUnavailable(treeId, indices, 'reserved');
|
|
97
98
|
const reservationId = randomId();
|
|
98
99
|
const expiresAt = Date.now() + ttlMs;
|
|
99
100
|
const lease = {
|
package/package.json
CHANGED