chore: add bootstrap nodes

This commit is contained in:
Danish Arora 2025-04-16 15:40:20 +05:30
parent 56c9c8d889
commit e3128876de
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E
2 changed files with 34 additions and 33 deletions

View File

@ -21,5 +21,9 @@ export const NETWORK_CONFIG: NetworkConfig = {
* Bootstrap nodes for the Waku network
* These are public Waku nodes that our node will connect to on startup
*/
export const BOOTSTRAP_NODES = [
];
export const BOOTSTRAP_NODES = {
"42": ["/dns4/waku-test.bloxy.one/tcp/8095/wss/p2p/16Uiu2HAmSZbDB7CusdRhgkD81VssRjQV5ZH13FbzCGcdnbbh6VwZ",
"/dns4/node-01.do-ams3.waku.sandbox.status.im/tcp/30303/p2p/16Uiu2HAmNaeL4p3WEYzC9mgXBmBWSgWjPHRvatZTXnp8Jgv3iKsb",
"/dns4/waku.fryorcraken.xyz/tcp/8000/wss/p2p/16Uiu2HAmMRvhDHrtiHft1FTUYnn6cVA8AWVrTyLUayJJ3MWpUZDB",
"/dns4/vps-aaa00d52.vps.ovh.ca/tcp/8000/wss/p2p/16Uiu2HAm9PftGgHZwWE3wzdMde4m3kT2eYJFXLZfGoSED3gysofk"]
};

View File

@ -32,7 +32,7 @@ class MessageManager {
defaultBootstrap: false,
networkConfig: NETWORK_CONFIG,
autoStart: true,
bootstrapPeers: BOOTSTRAP_NODES,
bootstrapPeers: BOOTSTRAP_NODES[42],
lightPush:{autoRetry: true, retryIntervalMs: 1000}
});
return new MessageManager(node);
@ -48,6 +48,32 @@ class MessageManager {
this.storeManager = new StoreManager(node);
}
public async queryStore() {
const messages = await this.storeManager.queryStore();
for (const message of messages) {
this.updateCache(message);
}
return messages;
}
public async sendMessage(message: OpchanMessage) {
await this.ephemeralProtocolsManager.sendMessage(message);
//TODO: should we update the cache here? or just from store/filter?
this.updateCache(message);
}
public async subscribeToMessages(types: MessageType[] = [MessageType.CELL, MessageType.POST, MessageType.COMMENT, MessageType.VOTE]) {
const { result, subscription } = await this.ephemeralProtocolsManager.subscribeToMessages(types);
for (const message of result) {
this.updateCache(message);
}
return { messages: result, subscription };
}
private updateCache(message: OpchanMessage) {
switch (message.type) {
case MessageType.CELL:
@ -72,36 +98,7 @@ class MessageManager {
}
}
public async queryStore() {
const messages = await this.storeManager.queryStore();
// Populate cache from store messages
for (const message of messages) {
this.updateCache(message);
}
return messages;
}
public async sendMessage(message: OpchanMessage) {
await this.ephemeralProtocolsManager.sendMessage(message);
// Also update local cache with the message we just sent
this.updateCache(message);
}
public async subscribeToMessages(types: MessageType[] = [MessageType.CELL, MessageType.POST, MessageType.COMMENT, MessageType.VOTE]) {
const { result, subscription } = await this.ephemeralProtocolsManager.subscribeToMessages(types);
// Set up a callback that will be triggered for new messages
// New messages from the subscription will be processed directly by the ephemeralProtocolsManager
// and returned via the result array, so we just need to add them to the cache
for (const message of result) {
this.updateCache(message);
}
// Return result and subscription for any external processing
return { messages: result, subscription };
}
}
const messageManager = await MessageManager.create();