From 1ce396b6e083fe0c583944e4a3a04126986bb07d Mon Sep 17 00:00:00 2001 From: Sasha <118575614+weboko@users.noreply.github.com> Date: Thu, 27 Jun 2024 01:16:29 +0200 Subject: [PATCH] chore: add FAQ and info for dialing a peer (#203) * chore: add FAQ and info for dialing a peer * fix spelling * add link * fix link * fix lock --- docs/guides/js-waku/configure-discovery.md | 31 +++++++++++++++++++++- docs/guides/js-waku/faq.md | 4 +++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/docs/guides/js-waku/configure-discovery.md b/docs/guides/js-waku/configure-discovery.md index bc060c6..05e98c6 100644 --- a/docs/guides/js-waku/configure-discovery.md +++ b/docs/guides/js-waku/configure-discovery.md @@ -52,8 +52,37 @@ const node = await createLightNode({ }); ``` +Alternatively, you can dial a particular node like this: + +```js +// Define the list of static peers to bootstrap +const peers = [ + "/ip4/0.0.0.0/tcp/60002/ws/p2p/16Uiu2HAkzjwwgEAXfeGNMKFPSpc6vGBRqCdTLG5q3Gmk2v4pQw7H", + "/ip4/0.0.0.0/tcp/60003/ws/p2p/16Uiu2HAmFBA7LGtwY5WVVikdmXVo3cKLqkmvVtuDu63fe8safeQJ", +]; + + +const node = await createLightNode(); + +// In case nodes are using `ws` protocol - additional configuration is needed: +/* +import { webSockets } from "@libp2p/websockets"; +import { all as filterAll } from "@libp2p/websockets/filters"; + +const node = await createLightNode({ + libp2p: { + transports: [webSockets({ filter: filterAll })], + }, +}); +*/ + +const promises = peers.map(multiaddr => node.dial(multiaddr)); + +await Promise.all(promises); +``` + :::tip -For local development using a `nwaku` node, use a `ws` address instead of `wss`. Remember that this setup is functional only when your web server is running locally. +For local development using a `nwaku` node, use a `ws` address instead of `wss`. Remember that this setup is functional only when your web server is running locally. You can check how to get multi address of your locally run node in [Find node address](/guides/nwaku/find-node-address). ::: ## Configure DNS discovery diff --git a/docs/guides/js-waku/faq.md b/docs/guides/js-waku/faq.md index cedd5b0..165fc38 100644 --- a/docs/guides/js-waku/faq.md +++ b/docs/guides/js-waku/faq.md @@ -49,3 +49,7 @@ import { AccordionItem } from '@site/src/components/mdx' While it's possible to transmit media such as images as bytes on Waku, we recommend uploading your media to a CDN or a file system like IPFS and then sharing the corresponding URL via Waku. + + + To manually set your own node as a starting point use Configure static peers. +