@peerbit/shared-log 11.0.6 → 11.0.7-3a4b77c
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/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/integers.d.ts +1 -0
- package/dist/src/integers.d.ts.map +1 -1
- package/dist/src/integers.js +8 -0
- package/dist/src/integers.js.map +1 -1
- package/dist/src/ranges.d.ts.map +1 -1
- package/dist/src/ranges.js +31 -17
- package/dist/src/ranges.js.map +1 -1
- package/package.json +70 -70
- package/src/index.ts +2 -2
- package/src/integers.ts +9 -0
- package/src/ranges.ts +40 -20
package/src/ranges.ts
CHANGED
|
@@ -2273,39 +2273,51 @@ export const getCoverSet = async <R extends "u32" | "u64">(properties: {
|
|
|
2273
2273
|
};
|
|
2274
2274
|
|
|
2275
2275
|
// fill the middle
|
|
2276
|
-
let wrappedOnce = current.end2 < current.end1;
|
|
2277
2276
|
|
|
2278
2277
|
let coveredLength = properties.numbers.zero;
|
|
2279
|
-
|
|
2280
|
-
|
|
2278
|
+
|
|
2279
|
+
let startIsMature = isMatured(startNode, now, roleAge);
|
|
2280
|
+
|
|
2281
|
+
let wrappedOnce = false;
|
|
2282
|
+
|
|
2283
|
+
const addLength = (
|
|
2284
|
+
to: ReplicationRangeIndexable<R>,
|
|
2285
|
+
from: NumberFromType<R>,
|
|
2286
|
+
) => {
|
|
2287
|
+
const toEnd2 = properties.numbers.increment(to.end2); // TODO investigate why this is needed
|
|
2288
|
+
if (toEnd2 < from || to.wrapped) {
|
|
2281
2289
|
wrappedOnce = true;
|
|
2282
2290
|
// @ts-ignore
|
|
2283
2291
|
coveredLength += properties.numbers.maxValue - from;
|
|
2284
2292
|
// @ts-ignore
|
|
2285
|
-
coveredLength +=
|
|
2293
|
+
coveredLength += toEnd2;
|
|
2286
2294
|
} else {
|
|
2287
2295
|
// @ts-ignore
|
|
2288
|
-
coveredLength +=
|
|
2296
|
+
coveredLength += to.end1 - from;
|
|
2289
2297
|
}
|
|
2290
2298
|
};
|
|
2291
|
-
addLength(startLocation);
|
|
2292
2299
|
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
let
|
|
2300
|
+
addLength(current, startLocation);
|
|
2301
|
+
|
|
2302
|
+
let maturedCoveredLength = startIsMature
|
|
2303
|
+
? coveredLength
|
|
2304
|
+
: 0; /* TODO we only increase matured length when startNode is matured? i.e. do isMatured(startNode, now, roleAge) ? coveredLength : 0;, however what is the optimal choice here? */
|
|
2305
|
+
let nextLocation = current.end2; /* startIsMature
|
|
2306
|
+
? current.end2
|
|
2307
|
+
: properties.numbers.increment(current.start1); */ // <--- this clause does not seem to work as expected (run ranges tests to see why)*/
|
|
2296
2308
|
|
|
2297
2309
|
while (
|
|
2298
2310
|
maturedCoveredLength < widthToCoverScaled && // eslint-disable-line no-unmodified-loop-condition
|
|
2299
|
-
coveredLength <= properties.numbers.maxValue // eslint-disable-line no-unmodified-loop-condition
|
|
2311
|
+
(coveredLength <= properties.numbers.maxValue || !wrappedOnce) // eslint-disable-line no-unmodified-loop-condition
|
|
2300
2312
|
) {
|
|
2313
|
+
let distanceBefore = coveredLength;
|
|
2314
|
+
|
|
2301
2315
|
let nextCandidate = await resolveNext(nextLocation, roleAge);
|
|
2302
|
-
/* let fromAbove = false; */
|
|
2303
2316
|
let matured = true;
|
|
2304
2317
|
|
|
2305
2318
|
if (!nextCandidate[0]) {
|
|
2306
2319
|
matured = false;
|
|
2307
2320
|
nextCandidate = await resolveNext(nextLocation, 0);
|
|
2308
|
-
/* fromAbove = true; */
|
|
2309
2321
|
}
|
|
2310
2322
|
|
|
2311
2323
|
if (!nextCandidate[0]) {
|
|
@@ -2313,15 +2325,20 @@ export const getCoverSet = async <R extends "u32" | "u64">(properties: {
|
|
|
2313
2325
|
}
|
|
2314
2326
|
|
|
2315
2327
|
let nextIsCurrent = equals(nextCandidate[0].id, current.id);
|
|
2328
|
+
let extraDistanceForNext = false;
|
|
2316
2329
|
if (nextIsCurrent) {
|
|
2317
|
-
|
|
2330
|
+
let containing = nextCandidate[1];
|
|
2331
|
+
if (containing) {
|
|
2332
|
+
extraDistanceForNext = true;
|
|
2333
|
+
} else {
|
|
2334
|
+
break;
|
|
2335
|
+
}
|
|
2318
2336
|
}
|
|
2319
|
-
let last = current;
|
|
2320
|
-
current = nextCandidate[0];
|
|
2321
2337
|
|
|
2322
|
-
|
|
2338
|
+
addLength(nextCandidate[0], nextLocation);
|
|
2323
2339
|
|
|
2324
|
-
|
|
2340
|
+
let last = current;
|
|
2341
|
+
current = nextCandidate[0];
|
|
2325
2342
|
|
|
2326
2343
|
let isLast =
|
|
2327
2344
|
distanceBefore < widthToCoverScaled &&
|
|
@@ -2370,11 +2387,14 @@ export const getCoverSet = async <R extends "u32" | "u64">(properties: {
|
|
|
2370
2387
|
maturedCoveredLength = coveredLength;
|
|
2371
2388
|
}
|
|
2372
2389
|
|
|
2390
|
+
let startForNext = extraDistanceForNext
|
|
2391
|
+
? properties.numbers.increment(current.end2)
|
|
2392
|
+
: current.end2;
|
|
2373
2393
|
nextLocation = endIsWrapped
|
|
2374
2394
|
? wrappedOnce
|
|
2375
|
-
? properties.numbers.min(
|
|
2376
|
-
:
|
|
2377
|
-
: properties.numbers.min(
|
|
2395
|
+
? properties.numbers.min(startForNext, endLocation)
|
|
2396
|
+
: startForNext
|
|
2397
|
+
: properties.numbers.min(startForNext, endLocation);
|
|
2378
2398
|
}
|
|
2379
2399
|
|
|
2380
2400
|
start instanceof PublicSignKey && ret.add(start.hashcode());
|