@bitsocial/pubsub-voting 0.1.2 → 0.1.3
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.
|
@@ -54,6 +54,24 @@ export interface VoteNode {
|
|
|
54
54
|
admitBundle(bundle: VotesBundle): Promise<void>;
|
|
55
55
|
stop(): Promise<void>;
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* One real loopback libp2p + Helia node carrying gossipsub (topic-scoped score params) and
|
|
59
|
+
* `@libp2p/fetch` — the raw host node with nothing else wired. {@link makeVoteNode} builds the
|
|
60
|
+
* harness transport on top of it; the three-node relay test instead hands it straight to the
|
|
61
|
+
* REAL `PubsubVoter` as the injected host node (the `PubsubVoterOptions.helia` seam).
|
|
62
|
+
*/
|
|
63
|
+
export declare function makeBareNode(topic: string): Promise<{
|
|
64
|
+
libp2p: Libp2p<{
|
|
65
|
+
identify: import("@libp2p/identify").Identify;
|
|
66
|
+
fetch: import("@libp2p/fetch").Fetch;
|
|
67
|
+
pubsub: import("@libp2p/gossipsub").GossipSub;
|
|
68
|
+
}>;
|
|
69
|
+
helia: Helia<Libp2p<{
|
|
70
|
+
identify: import("@libp2p/identify").Identify;
|
|
71
|
+
fetch: import("@libp2p/fetch").Fetch;
|
|
72
|
+
pubsub: import("@libp2p/gossipsub").GossipSub;
|
|
73
|
+
}>>;
|
|
74
|
+
}>;
|
|
57
75
|
/** Build one real node with the full forward-gate wired to real gossipsub. */
|
|
58
76
|
export declare function makeVoteNode(topic: string, options?: VoteNodeOptions): Promise<VoteNode>;
|
|
59
77
|
/**
|
|
@@ -38,9 +38,13 @@ const BLOCKS_PER_BUCKET = 43_200;
|
|
|
38
38
|
const VOTE_EXPIRY_BUCKETS = 30;
|
|
39
39
|
/** A permissive default verifier; individual tests swap it via {@link VoteNode.setVerifier}. */
|
|
40
40
|
const okVerifier = () => ({ valid: true, ruleScore: 1n, resolvedNames: {} });
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
/**
|
|
42
|
+
* One real loopback libp2p + Helia node carrying gossipsub (topic-scoped score params) and
|
|
43
|
+
* `@libp2p/fetch` — the raw host node with nothing else wired. {@link makeVoteNode} builds the
|
|
44
|
+
* harness transport on top of it; the three-node relay test instead hands it straight to the
|
|
45
|
+
* REAL `PubsubVoter` as the injected host node (the `PubsubVoterOptions.helia` seam).
|
|
46
|
+
*/
|
|
47
|
+
export async function makeBareNode(topic) {
|
|
44
48
|
const libp2p = await createLibp2p({
|
|
45
49
|
addresses: { listen: ["/ip4/127.0.0.1/tcp/0"] },
|
|
46
50
|
transports: [tcp()],
|
|
@@ -87,6 +91,12 @@ export async function makeVoteNode(topic, options = {}) {
|
|
|
87
91
|
}
|
|
88
92
|
});
|
|
89
93
|
const helia = await createHelia({ libp2p });
|
|
94
|
+
return { libp2p, helia };
|
|
95
|
+
}
|
|
96
|
+
/** Build one real node with the full forward-gate wired to real gossipsub. */
|
|
97
|
+
export async function makeVoteNode(topic, options = {}) {
|
|
98
|
+
const timeoutMs = options.timeoutMs ?? 10_000;
|
|
99
|
+
const { libp2p, helia } = await makeBareNode(topic);
|
|
90
100
|
const pubsub = libp2p.services.pubsub;
|
|
91
101
|
// Adapt Helia's async-generator `get` to the library's Promise-returning BlockstoreLike, the
|
|
92
102
|
// same bridge `requireHeliaServices` applies to an injected host node.
|