@peerbit/shared-log 13.1.15 → 13.1.16
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.d.ts.map +1 -1
- package/dist/src/index.js +20 -22
- package/dist/src/index.js.map +1 -1
- package/package.json +9 -9
- package/src/index.ts +22 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peerbit/shared-log",
|
|
3
|
-
"version": "13.1.
|
|
3
|
+
"version": "13.1.16",
|
|
4
4
|
"description": "Shared log",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -63,18 +63,18 @@
|
|
|
63
63
|
"uint8arrays": "^5.1.0",
|
|
64
64
|
"@peerbit/any-store": "2.2.9",
|
|
65
65
|
"@peerbit/blocks-interface": "2.0.11",
|
|
66
|
-
"@peerbit/blocks": "4.1.7",
|
|
67
|
-
"@peerbit/cache": "3.0.0",
|
|
68
66
|
"@peerbit/crypto": "3.1.1",
|
|
67
|
+
"@peerbit/blocks": "4.1.8",
|
|
69
68
|
"@peerbit/indexer-interface": "3.0.3",
|
|
70
|
-
"@peerbit/
|
|
71
|
-
"@peerbit/program": "6.0.28",
|
|
72
|
-
"@peerbit/logger": "2.0.1",
|
|
69
|
+
"@peerbit/cache": "3.0.0",
|
|
73
70
|
"@peerbit/indexer-sqlite3": "3.0.6",
|
|
74
|
-
"@peerbit/
|
|
71
|
+
"@peerbit/log": "6.0.35",
|
|
72
|
+
"@peerbit/logger": "2.0.1",
|
|
73
|
+
"@peerbit/program": "6.0.29",
|
|
74
|
+
"@peerbit/pubsub": "5.2.10",
|
|
75
75
|
"@peerbit/pubsub-interface": "5.1.3",
|
|
76
|
+
"@peerbit/rpc": "6.0.33",
|
|
76
77
|
"@peerbit/riblt": "1.2.0",
|
|
77
|
-
"@peerbit/rpc": "6.0.32",
|
|
78
78
|
"@peerbit/stream-interface": "6.0.9",
|
|
79
79
|
"@peerbit/time": "3.0.0"
|
|
80
80
|
},
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@types/libsodium-wrappers": "^0.7.14",
|
|
83
83
|
"@types/pidusage": "^2.0.5",
|
|
84
84
|
"uuid": "^10.0.0",
|
|
85
|
-
"@peerbit/test-utils": "3.0.
|
|
85
|
+
"@peerbit/test-utils": "3.0.33"
|
|
86
86
|
},
|
|
87
87
|
"repository": {
|
|
88
88
|
"type": "git",
|
package/src/index.ts
CHANGED
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
} from "@peerbit/time";
|
|
71
71
|
import pDefer, { type DeferredPromise } from "p-defer";
|
|
72
72
|
import PQueue from "p-queue";
|
|
73
|
-
import { concat } from "uint8arrays";
|
|
73
|
+
import { concat, fromString } from "uint8arrays";
|
|
74
74
|
import { BlocksMessage } from "./blocks.js";
|
|
75
75
|
import { type CPUUsage, CPUUsageIntervalLag } from "./cpu.js";
|
|
76
76
|
import {
|
|
@@ -2065,6 +2065,14 @@ export class SharedLog<
|
|
|
2065
2065
|
) => void;
|
|
2066
2066
|
},
|
|
2067
2067
|
) {
|
|
2068
|
+
const entryRangeId = (entry: Entry<T>) =>
|
|
2069
|
+
sha256Sync(
|
|
2070
|
+
concat([
|
|
2071
|
+
this.log.id,
|
|
2072
|
+
fromString(entry.hash),
|
|
2073
|
+
fromString(this.node.identity.publicKey.hashcode()),
|
|
2074
|
+
]),
|
|
2075
|
+
);
|
|
2068
2076
|
let range:
|
|
2069
2077
|
| ReplicationRangeMessage<any>[]
|
|
2070
2078
|
| ReplicationOptions<R>
|
|
@@ -2074,6 +2082,7 @@ export class SharedLog<
|
|
|
2074
2082
|
range = rangeOrEntry;
|
|
2075
2083
|
} else if (rangeOrEntry instanceof Entry) {
|
|
2076
2084
|
range = {
|
|
2085
|
+
id: entryRangeId(rangeOrEntry),
|
|
2077
2086
|
factor: 1,
|
|
2078
2087
|
offset: await this.domain.fromEntry(rangeOrEntry),
|
|
2079
2088
|
normalized: false,
|
|
@@ -2084,6 +2093,7 @@ export class SharedLog<
|
|
|
2084
2093
|
for (const entry of rangeOrEntry) {
|
|
2085
2094
|
if (entry instanceof Entry) {
|
|
2086
2095
|
ranges.push({
|
|
2096
|
+
id: entryRangeId(entry),
|
|
2087
2097
|
factor: 1,
|
|
2088
2098
|
offset: await this.domain.fromEntry(entry),
|
|
2089
2099
|
normalized: false,
|
|
@@ -3514,26 +3524,18 @@ export class SharedLog<
|
|
|
3514
3524
|
const frontierTargets = this._repairFrontierByMode.get(mode);
|
|
3515
3525
|
for (const target of pendingPeersByMode.get(mode) ?? []) {
|
|
3516
3526
|
const replacement = nextTargets.get(target);
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
existing.set(hash, entry);
|
|
3526
|
-
}
|
|
3527
|
-
} else {
|
|
3528
|
-
frontierTargets?.set(target, replacement);
|
|
3527
|
+
// These repairs are receipt-driven: a later sweep can have a narrower
|
|
3528
|
+
// transient leader view, but it must not forget unconfirmed hashes
|
|
3529
|
+
// that were already queued for this target.
|
|
3530
|
+
if (replacement && replacement.size > 0) {
|
|
3531
|
+
const existing = frontierTargets?.get(target);
|
|
3532
|
+
if (existing && existing.size > 0) {
|
|
3533
|
+
for (const [hash, entry] of replacement) {
|
|
3534
|
+
existing.set(hash, entry);
|
|
3529
3535
|
}
|
|
3536
|
+
} else {
|
|
3537
|
+
frontierTargets?.set(target, replacement);
|
|
3530
3538
|
}
|
|
3531
|
-
continue;
|
|
3532
|
-
}
|
|
3533
|
-
if (replacement && replacement.size > 0) {
|
|
3534
|
-
frontierTargets?.set(target, replacement);
|
|
3535
|
-
} else {
|
|
3536
|
-
frontierTargets?.delete(target);
|
|
3537
3539
|
}
|
|
3538
3540
|
}
|
|
3539
3541
|
}
|
|
@@ -6072,7 +6074,7 @@ export class SharedLog<
|
|
|
6072
6074
|
|
|
6073
6075
|
await this.replicate(entriesToReplicate, {
|
|
6074
6076
|
rebalance: assumeSynced ? false : true,
|
|
6075
|
-
checkDuplicates: true,
|
|
6077
|
+
checkDuplicates: assumeSynced ? false : true,
|
|
6076
6078
|
mergeSegments:
|
|
6077
6079
|
typeof options.replicate !== "boolean" && options.replicate
|
|
6078
6080
|
? options.replicate.mergeSegments
|