mirror of
https://github.com/logos-messaging/examples.waku.org.git
synced 2026-01-05 22:33:08 +00:00
feat: setup node to use autosharding in rln-js
This commit is contained in:
parent
504bcd4431
commit
d99a7da194
1626
examples/rln-js/package-lock.json
generated
1626
examples/rln-js/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -10,8 +10,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@waku/rln": "0.1.1-0fbf6be",
|
||||
"@waku/sdk": "^0.0.20",
|
||||
"@waku/utils": "^0.0.12",
|
||||
"@waku/sdk": "0.0.22",
|
||||
"@waku/utils": "0.0.14",
|
||||
"ethers": "^5.7.2",
|
||||
"multiaddr": "^10.0.1",
|
||||
"next": "13.5.6",
|
||||
@ -22,6 +22,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@metamask/types": "^1.1.0",
|
||||
"@multiformats/multiaddr-matcher": "^1.1.2",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^18",
|
||||
"@types/react-dom": "^18",
|
||||
|
||||
@ -19,6 +19,7 @@ import {
|
||||
RLNContract,
|
||||
} from "@waku/rln";
|
||||
import { RLN } from "@/services/rln";
|
||||
import { contentTopicToShardIndex } from "@waku/utils";
|
||||
|
||||
type InitOptions = {
|
||||
membershipID: number;
|
||||
@ -84,12 +85,15 @@ export class Waku implements IWaku {
|
||||
this.initEncoder(options);
|
||||
this.decoder = new RLNDecoder(
|
||||
options.rln.rlnInstance,
|
||||
createDecoder(this.contentTopic)
|
||||
createDecoder(this.contentTopic, { clusterId: 1 })
|
||||
);
|
||||
|
||||
if (!this.node) {
|
||||
this.emitStatusEvent(WakuStatusEventPayload.INITIALIZING);
|
||||
this.node = await createLightNode({ defaultBootstrap: true });
|
||||
this.node = await createLightNode({
|
||||
defaultBootstrap: true,
|
||||
shardInfo: { clusterId: 1, contentTopics: [CONTENT_TOPIC] },
|
||||
});
|
||||
this.emitStatusEvent(WakuStatusEventPayload.STARTING);
|
||||
await this.node.start();
|
||||
this.emitStatusEvent(WakuStatusEventPayload.WAITING_FOR_PEERS);
|
||||
@ -119,6 +123,7 @@ export class Waku implements IWaku {
|
||||
createEncoder({
|
||||
ephemeral: false,
|
||||
contentTopic: this.contentTopic,
|
||||
pubsubTopicShardInfo: { clusterId: 1 },
|
||||
}),
|
||||
rln.rlnInstance,
|
||||
membershipID,
|
||||
@ -145,7 +150,11 @@ export class Waku implements IWaku {
|
||||
}
|
||||
|
||||
private async subscribeToMessages(options: SubscribeOptions) {
|
||||
await options.node.filter.subscribe(options.decoder, (message) => {
|
||||
const subscription = await options.node.filter.createSubscription({
|
||||
clusterId: 1,
|
||||
shard: contentTopicToShardIndex(CONTENT_TOPIC),
|
||||
});
|
||||
await subscription.subscribe(options.decoder, (message) => {
|
||||
try {
|
||||
const { timestamp, nick, text } = ProtoChatMessage.decode(
|
||||
message.payload
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user