@peerbit/shared-log 13.2.5 → 13.2.7
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/errors.d.ts +19 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +40 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/index.d.ts +72 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3251 -541
- package/dist/src/index.js.map +1 -1
- package/package.json +23 -23
- package/src/errors.ts +62 -0
- package/src/index.ts +4431 -879
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peerbit/shared-log",
|
|
3
|
-
"version": "13.2.
|
|
3
|
+
"version": "13.2.7",
|
|
4
4
|
"description": "Shared log",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
|
-
"author": "
|
|
52
|
+
"author": "Peerbit contributors",
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@dao-xyz/borsh": "^6.0.0",
|
|
@@ -61,36 +61,36 @@
|
|
|
61
61
|
"pidusage": "^4.0.1",
|
|
62
62
|
"pino": "^9.4.0",
|
|
63
63
|
"uint8arrays": "^5.1.0",
|
|
64
|
-
"@peerbit/
|
|
65
|
-
"@peerbit/
|
|
64
|
+
"@peerbit/blocks-interface": "2.1.1",
|
|
65
|
+
"@peerbit/any-store": "2.2.11",
|
|
66
|
+
"@peerbit/blocks": "4.2.3",
|
|
66
67
|
"@peerbit/cache": "3.1.0",
|
|
67
|
-
"@peerbit/
|
|
68
|
-
"@peerbit/crypto": "3.1.2",
|
|
68
|
+
"@peerbit/crypto": "3.1.3",
|
|
69
69
|
"@peerbit/diagnostics": "0.0.1",
|
|
70
|
-
"@peerbit/indexer-interface": "3.0.
|
|
71
|
-
"@peerbit/indexer-sqlite3": "3.0.
|
|
72
|
-
"@peerbit/log": "6.2.
|
|
70
|
+
"@peerbit/indexer-interface": "3.0.7",
|
|
71
|
+
"@peerbit/indexer-sqlite3": "3.0.10",
|
|
72
|
+
"@peerbit/log": "6.2.6",
|
|
73
73
|
"@peerbit/logger": "2.0.1",
|
|
74
|
-
"@peerbit/
|
|
75
|
-
"@peerbit/pubsub-interface": "5.1.5",
|
|
74
|
+
"@peerbit/pubsub": "5.3.1",
|
|
76
75
|
"@peerbit/riblt": "1.2.0",
|
|
77
|
-
"@peerbit/rpc": "6.1.
|
|
78
|
-
"@peerbit/pubsub": "5.
|
|
79
|
-
"@peerbit/
|
|
80
|
-
"@peerbit/time": "3.0.
|
|
76
|
+
"@peerbit/rpc": "6.1.4",
|
|
77
|
+
"@peerbit/pubsub-interface": "5.1.6",
|
|
78
|
+
"@peerbit/program": "6.0.36",
|
|
79
|
+
"@peerbit/time": "3.0.1",
|
|
80
|
+
"@peerbit/stream-interface": "6.0.12"
|
|
81
81
|
},
|
|
82
82
|
"optionalDependencies": {
|
|
83
|
-
"@peerbit/native-backbone": "0.
|
|
84
|
-
"@peerbit/shared-log-rust": "0.1.
|
|
83
|
+
"@peerbit/native-backbone": "0.2.0",
|
|
84
|
+
"@peerbit/shared-log-rust": "0.1.3"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@types/libsodium-wrappers": "^0.7.14",
|
|
88
88
|
"@types/pidusage": "^2.0.5",
|
|
89
|
-
"uuid": "^
|
|
90
|
-
"@peerbit/
|
|
91
|
-
"@peerbit/
|
|
92
|
-
"@peerbit/test-utils": "3.1.
|
|
93
|
-
"peerbit": "5.3.
|
|
89
|
+
"uuid": "^11.1.1",
|
|
90
|
+
"@peerbit/indexer-rust": "1.0.5",
|
|
91
|
+
"@peerbit/any-store-rust": "0.1.2",
|
|
92
|
+
"@peerbit/test-utils": "3.1.7",
|
|
93
|
+
"peerbit": "5.3.7"
|
|
94
94
|
},
|
|
95
95
|
"repository": {
|
|
96
96
|
"type": "git",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"benchmark:sync-catchup": "node --loader ts-node/esm ./benchmark/sync-catchup.ts",
|
|
114
114
|
"benchmark:sync-phase-profile": "node --loader ts-node/esm ./benchmark/sync-phase-profile.ts",
|
|
115
115
|
"test": "aegir test --target node",
|
|
116
|
-
"test:shared-log-rust-core": "npm run build && PEERBIT_SHARED_LOG_RUST_CORE=1 aegir test -t node --grep '^(?!.*(does not fetch missing entries from remotes|will prune once reaching max replicas|repairs when joiner request responses are dropped|time out when pending IHave are never resolved|does not confirm checked prune from a shallow-only entry|replication degree update ))(append delivery options |join |replicate |(u32-simple|u64-iblt) (replication references |replication replication (one way|two way) |redundancy only sends entries once|canReplicate |replication degree |start/stop replicate on connect|sync ))'",
|
|
116
|
+
"test:shared-log-rust-core": "npm run build && PEERBIT_SHARED_LOG_RUST_CORE=1 aegir test -t node --grep '^(?!u32-simple replication degree commit options control per commmit put before join converges under deterministic pubsub chaos$)(?!.*(does not fetch missing entries from remotes|will prune once reaching max replicas|repairs when joiner request responses are dropped|time out when pending IHave are never resolved|does not confirm checked prune from a shallow-only entry|replication degree update ))(append delivery options |join |replicate |(u32-simple|u64-iblt) (replication references |replication replication (one way|two way) |redundancy only sends entries once|canReplicate |replication degree |start/stop replicate on connect|sync ))' -- --forbid-pending",
|
|
117
117
|
"lint": "aegir lint",
|
|
118
118
|
"test:cov": "aegir test -t node --cov"
|
|
119
119
|
}
|
package/src/errors.ts
CHANGED
|
@@ -5,3 +5,65 @@ export class NoPeersError extends Error {
|
|
|
5
5
|
);
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The native transaction committed hot/runtime facts before its entry block
|
|
11
|
+
* could be mirrored to durable storage. Lower-log publication is held behind
|
|
12
|
+
* the mirror barrier, but blindly retrying the user operation is unsafe because
|
|
13
|
+
* native state may already contain the attempted commit.
|
|
14
|
+
*/
|
|
15
|
+
export class NativeDurableCommitError extends Error {
|
|
16
|
+
readonly nativeCommitApplied = true;
|
|
17
|
+
readonly retrySafe = false;
|
|
18
|
+
readonly cause: unknown;
|
|
19
|
+
readonly committedCids: readonly string[];
|
|
20
|
+
readonly failedCids: readonly string[];
|
|
21
|
+
private readonly committedCidList: string[];
|
|
22
|
+
private readonly failedCidList: string[];
|
|
23
|
+
|
|
24
|
+
constructor(
|
|
25
|
+
cause: unknown,
|
|
26
|
+
options?: {
|
|
27
|
+
committedCids?: Iterable<string>;
|
|
28
|
+
failedCids?: Iterable<string>;
|
|
29
|
+
},
|
|
30
|
+
) {
|
|
31
|
+
const committedCids = [...(options?.committedCids ?? [])];
|
|
32
|
+
const failedCids = [...(options?.failedCids ?? committedCids)];
|
|
33
|
+
super(
|
|
34
|
+
`Native commit applied but a durable block mutation failed; automatic retry is unsafe: ${
|
|
35
|
+
cause instanceof Error ? cause.message : String(cause)
|
|
36
|
+
}${failedCids.length > 0 ? ` (failed CIDs: ${failedCids.join(", ")})` : ""}`,
|
|
37
|
+
);
|
|
38
|
+
this.name = "NativeDurableCommitError";
|
|
39
|
+
this.cause = cause;
|
|
40
|
+
this.committedCidList = committedCids;
|
|
41
|
+
this.failedCidList = failedCids;
|
|
42
|
+
this.committedCids = this.committedCidList;
|
|
43
|
+
this.failedCids = this.failedCidList;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** @internal Merge facts from other mutations covered by the same poison. */
|
|
47
|
+
addCommitContext(
|
|
48
|
+
options?: {
|
|
49
|
+
committedCids?: Iterable<string>;
|
|
50
|
+
failedCids?: Iterable<string>;
|
|
51
|
+
},
|
|
52
|
+
properties?: { preferIncomingOrder?: boolean },
|
|
53
|
+
): void {
|
|
54
|
+
const merge = (
|
|
55
|
+
target: string[],
|
|
56
|
+
incoming: Iterable<string> | undefined,
|
|
57
|
+
): void => {
|
|
58
|
+
if (!incoming) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const values = properties?.preferIncomingOrder
|
|
62
|
+
? [...incoming, ...target]
|
|
63
|
+
: [...target, ...incoming];
|
|
64
|
+
target.splice(0, target.length, ...new Set(values));
|
|
65
|
+
};
|
|
66
|
+
merge(this.committedCidList, options?.committedCids);
|
|
67
|
+
merge(this.failedCidList, options?.failedCids);
|
|
68
|
+
}
|
|
69
|
+
}
|