@bitsocial/pubsub-voting 0.6.1 → 0.7.0
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Libp2p } from "libp2p";
|
|
2
2
|
import { type Helia } from "helia";
|
|
3
3
|
import type { VotesBundle } from "../../schema/votes.js";
|
|
4
4
|
import type { BundleVerdict } from "../../verify/types.js";
|
|
@@ -66,11 +66,11 @@ export declare function makeBareNode(topic: string): Promise<{
|
|
|
66
66
|
fetch: import("@libp2p/fetch").Fetch;
|
|
67
67
|
pubsub: import("@libp2p/gossipsub").GossipSub;
|
|
68
68
|
}>;
|
|
69
|
-
helia:
|
|
69
|
+
helia: import("@helia/libp2p").HeliaWithLibp2p<{
|
|
70
70
|
identify: import("@libp2p/identify").Identify;
|
|
71
71
|
fetch: import("@libp2p/fetch").Fetch;
|
|
72
72
|
pubsub: import("@libp2p/gossipsub").GossipSub;
|
|
73
|
-
}
|
|
73
|
+
}>;
|
|
74
74
|
}>;
|
|
75
75
|
/** Build one real node with the full forward-gate wired to real gossipsub. */
|
|
76
76
|
export declare function makeVoteNode(topic: string, options?: VoteNodeOptions): Promise<VoteNode>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import pLimit from "p-limit";
|
|
2
|
-
import { createLibp2p } from "libp2p";
|
|
3
2
|
import { tcp } from "@libp2p/tcp";
|
|
4
3
|
import { noise } from "@chainsafe/libp2p-noise";
|
|
5
4
|
import { yamux } from "@chainsafe/libp2p-yamux";
|
|
6
5
|
import { identify } from "@libp2p/identify";
|
|
7
6
|
import { gossipsub } from "@libp2p/gossipsub";
|
|
8
7
|
import { fetch as fetchService } from "@libp2p/fetch";
|
|
9
|
-
import {
|
|
8
|
+
import { createHeliaLight } from "helia";
|
|
9
|
+
import { withLibp2pLight } from "@helia/libp2p";
|
|
10
|
+
import { withBitswap } from "@helia/bitswap";
|
|
10
11
|
import { makeBlockstoreBundleStore } from "../bundle-store.js";
|
|
11
12
|
import { adaptBlockstore } from "../helia.js";
|
|
12
13
|
import { makeVoteCrdt } from "../../crdt/crdt.js";
|
|
@@ -45,7 +46,12 @@ const okVerifier = () => ({ valid: true, resolvedNames: {} });
|
|
|
45
46
|
* REAL `PubsubVoter` as the injected host node (the `PubsubVoterOptions.helia` seam).
|
|
46
47
|
*/
|
|
47
48
|
export async function makeBareNode(topic) {
|
|
48
|
-
|
|
49
|
+
// Helia 7 no longer takes a pre-built libp2p instance — it constructs libp2p itself
|
|
50
|
+
// inside `start()` from the options passed to `withLibp2p(Light)`. Compose the node the
|
|
51
|
+
// way the pkc-js host does (`withBitswap(withLibp2p*(createHeliaLight(...)))`), using
|
|
52
|
+
// the Light variants so no default service (DHT, relay, bootstrap, public HTTP brokers)
|
|
53
|
+
// leaks into the hermetic loopback tests.
|
|
54
|
+
const helia = withBitswap(withLibp2pLight(createHeliaLight(), {
|
|
49
55
|
addresses: { listen: ["/ip4/127.0.0.1/tcp/0"] },
|
|
50
56
|
transports: [tcp()],
|
|
51
57
|
connectionEncrypters: [noise()],
|
|
@@ -89,9 +95,11 @@ export async function makeBareNode(topic) {
|
|
|
89
95
|
}
|
|
90
96
|
})
|
|
91
97
|
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
}));
|
|
99
|
+
// Helia 7 creates libp2p lazily inside `start()` — the `helia.libp2p` getter throws
|
|
100
|
+
// NotStartedError until then — so start before handing the node out.
|
|
101
|
+
await helia.start();
|
|
102
|
+
return { libp2p: helia.libp2p, helia };
|
|
95
103
|
}
|
|
96
104
|
/** Build one real node with the full forward-gate wired to real gossipsub. */
|
|
97
105
|
export async function makeVoteNode(topic, options = {}) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CID } from "multiformats/cid";
|
|
2
|
-
import type { PeerId } from "@libp2p/interface";
|
|
2
|
+
import type { Libp2p, PeerId, ServiceMap } from "@libp2p/interface";
|
|
3
3
|
import type { Helia } from "helia";
|
|
4
4
|
import type { RootRecord } from "./messages.js";
|
|
5
5
|
/**
|
|
@@ -180,12 +180,16 @@ export interface BlockSessionLike {
|
|
|
180
180
|
close(): void;
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
|
-
* The host's running Helia node, as injected into {@link PubsubVoter}.
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
183
|
+
* The host's running Helia node, as injected into {@link PubsubVoter}. Helia 7 made the
|
|
184
|
+
* base `Helia` network-agnostic (`libp2p` moved to `@helia/libp2p`'s `HeliaWithLibp2p`),
|
|
185
|
+
* so the libp2p handle is required structurally here, typed with the loose `ServiceMap` —
|
|
186
|
+
* `libp2p.services.pubsub` is `unknown` and cannot be trusted at compile time (a plain
|
|
187
|
+
* Helia node has no pubsub) — `requireHeliaServices` validates the gossipsub service and
|
|
188
|
+
* the blockstore at construction and narrows them.
|
|
187
189
|
*/
|
|
188
|
-
export type HeliaInstance = Helia
|
|
190
|
+
export type HeliaInstance = Helia & {
|
|
191
|
+
libp2p: Libp2p<ServiceMap>;
|
|
192
|
+
};
|
|
189
193
|
/** Live-delta propagation over pubsub (one inline bundle per message + root heartbeats). */
|
|
190
194
|
export interface VoteTransport {
|
|
191
195
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitsocial/pubsub-voting",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Trustless pubsub voting over a shared libp2p/Helia node.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@ipld/dag-cbor": "
|
|
50
|
-
"@libp2p/interface": "3.
|
|
49
|
+
"@ipld/dag-cbor": "10.0.2",
|
|
50
|
+
"@libp2p/interface": "3.3.0",
|
|
51
51
|
"better-sqlite3": "12.9.0",
|
|
52
|
-
"helia": "
|
|
52
|
+
"helia": "7.1.10",
|
|
53
53
|
"localforage": "1.10.0",
|
|
54
|
-
"multiformats": "14.0.
|
|
55
|
-
"p-limit": "
|
|
56
|
-
"viem": "2.
|
|
54
|
+
"multiformats": "14.0.5",
|
|
55
|
+
"p-limit": "7.3.1",
|
|
56
|
+
"viem": "2.56.0",
|
|
57
57
|
"zod": "4.3.6"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
@@ -61,23 +61,25 @@
|
|
|
61
61
|
"@chainsafe/libp2p-yamux": "8.0.1",
|
|
62
62
|
"@commitlint/cli": "20.4.3",
|
|
63
63
|
"@commitlint/config-conventional": "20.4.3",
|
|
64
|
-
"@helia/
|
|
65
|
-
"@
|
|
66
|
-
"@libp2p
|
|
67
|
-
"@libp2p/
|
|
68
|
-
"@libp2p/
|
|
64
|
+
"@helia/bitswap": "4.0.14",
|
|
65
|
+
"@helia/delegated-routing-v1-http-api-client": "9.0.2",
|
|
66
|
+
"@helia/libp2p": "2.1.3",
|
|
67
|
+
"@libp2p/fetch": "4.1.12",
|
|
68
|
+
"@libp2p/gossipsub": "17.0.1",
|
|
69
|
+
"@libp2p/identify": "4.1.13",
|
|
70
|
+
"@libp2p/tcp": "11.0.27",
|
|
69
71
|
"@multiformats/multiaddr": "13.0.3",
|
|
70
|
-
"@pkcprotocol/pkc-js": "0.0.
|
|
72
|
+
"@pkcprotocol/pkc-js": "0.0.89",
|
|
71
73
|
"@release-it/conventional-changelog": "10.0.6",
|
|
72
74
|
"@types/better-sqlite3": "7.6.13",
|
|
73
|
-
"@vitest/coverage-v8": "4.1.
|
|
75
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
74
76
|
"commitizen": "4.3.1",
|
|
75
77
|
"cz-conventional-changelog": "3.3.0",
|
|
76
78
|
"husky": "9.1.7",
|
|
77
|
-
"libp2p": "3.3.
|
|
79
|
+
"libp2p": "3.3.9",
|
|
78
80
|
"release-it": "19.2.4",
|
|
79
81
|
"strip-json-comments": "5.0.3",
|
|
80
82
|
"typescript": "5.9.3",
|
|
81
|
-
"vitest": "4.1.
|
|
83
|
+
"vitest": "4.1.11"
|
|
82
84
|
}
|
|
83
85
|
}
|