Skip to content

Commit

Permalink
docs: update documentation [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
aegir[bot] committed Dec 4, 2023
1 parent 3a535a0 commit 7ba656f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions classes/PubSubPeerDiscovery.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion functions/pubsubPeerDiscovery-1.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>@libp2p/pubsub-peer-discovery</title><meta name="description" content="Documentation for @libp2p/pubsub-peer-discovery"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script defer src="assets/main.js"></script><script async src="assets/search.js" id="tsd-search-script"></script><script async src="assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base="."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">@libp2p/pubsub-peer-discovery</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><h2>@libp2p/pubsub-peer-discovery</h2></div><div class="tsd-panel tsd-typography"><p><a href="http://libp2p.io/"><img src="https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square" alt="libp2p.io"></a>
<a href="https://discuss.libp2p.io"><img src="https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square" alt="Discuss"></a>
<a href="https://codecov.io/gh/libp2p/js-libp2p-pubsub-peer-discovery"><img src="https://img.shields.io/codecov/c/github/libp2p/js-libp2p-pubsub-peer-discovery.svg?style=flat-square" alt="codecov"></a>
<a href="https://github.com/libp2p/js-libp2p-pubsub-peer-discovery/actions/workflows/js-test-and-release.yml?query=branch%3Amain"><img src="https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-pubsub-peer-discovery/js-test-and-release.yml?branch=master&style=flat-square" alt="CI"></a></p>
<a href="https://github.com/libp2p/js-libp2p-pubsub-peer-discovery/actions/workflows/js-test-and-release.yml?query=branch%3Amain"><img src="https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-pubsub-peer-discovery/js-test-and-release.yml?branch=main&style=flat-square" alt="CI"></a></p>
<blockquote>
<p>A libp2p module that uses pubsub for mdns like peer discovery</p>
</blockquote>
Expand All @@ -13,7 +13,7 @@
<p>For more information see the <a href="https://github.com/libp2p/js-libp2p/blob/main/doc/CONFIGURATION.md#customizing-libp2p">docs on customizing libp2p</a>.</p>
<a id="md:example---usage-in-js-libp2p" class="tsd-anchor"></a><h2><a href="#md:example---usage-in-js-libp2p">Example - Usage in js-libp2p</a></h2><p>See the <a href="https://github.com/libp2p/js-libp2p/blob/main/doc/CONFIGURATION.md#customizing-peer-discovery">js-libp2p configuration docs</a> for how to include this module as a peer discovery module in js-libp2p.</p>
<p>If you are only interested in listening to the global pubsub topic the minimal configuration for using this with libp2p is:</p>
<pre><code class="language-js"><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">createLibp2p</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;libp2p&#39;</span><br/><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">websockets</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;@libp2p/websockets&#39;</span><br/><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">yamux</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;@chainsafe/libp2p-yamux&#39;</span><br/><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">noise</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;@chainsafe/libp2p-noise&#39;</span><br/><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">gossipsub</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;@chainsafe/libp2p-gossipsub&#39;</span><br/><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">pubsubPeerDiscovery</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;@libp2p/pubsub-peer-discovery&#39;</span><br/><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">identify</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;libp2p/identify&#39;</span><br/><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-5">node</span><span class="hl-1"> = </span><span class="hl-0">await</span><span class="hl-1"> </span><span class="hl-6">createLibp2p</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-2">transports:</span><span class="hl-1"> [</span><br/><span class="hl-1"> </span><span class="hl-6">websockets</span><span class="hl-1">()</span><br/><span class="hl-1"> ], </span><span class="hl-7">// Any libp2p transport(s) can be used</span><br/><span class="hl-1"> </span><span class="hl-2">streamMuxers:</span><span class="hl-1"> [</span><br/><span class="hl-1"> </span><span class="hl-6">mplex</span><span class="hl-1">()</span><br/><span class="hl-1"> ],</span><br/><span class="hl-1"> </span><span class="hl-2">connectionEncryption:</span><span class="hl-1"> [</span><br/><span class="hl-1"> </span><span class="hl-6">yamux</span><span class="hl-1">()</span><br/><span class="hl-1"> ],</span><br/><span class="hl-1"> </span><span class="hl-2">peerDiscovery:</span><span class="hl-1"> [</span><br/><span class="hl-1"> </span><span class="hl-6">pubsubPeerDiscovery</span><span class="hl-1">()</span><br/><span class="hl-1"> ],</span><br/><span class="hl-1"> </span><span class="hl-2">services:</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-2">pubsub:</span><span class="hl-1"> </span><span class="hl-6">gossipsub</span><span class="hl-1">(),</span><br/><span class="hl-1"> </span><span class="hl-2">identify:</span><span class="hl-1"> </span><span class="hl-6">identify</span><span class="hl-1">()</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">})</span>
<pre><code class="language-js"><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">createLibp2p</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;libp2p&#39;</span><br/><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">websockets</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;@libp2p/websockets&#39;</span><br/><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">yamux</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;@chainsafe/libp2p-yamux&#39;</span><br/><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">noise</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;@chainsafe/libp2p-noise&#39;</span><br/><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">gossipsub</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;@chainsafe/libp2p-gossipsub&#39;</span><br/><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">pubsubPeerDiscovery</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;@libp2p/pubsub-peer-discovery&#39;</span><br/><span class="hl-0">import</span><span class="hl-1"> { </span><span class="hl-2">identify</span><span class="hl-1"> } </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;libp2p/identify&#39;</span><br/><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-5">node</span><span class="hl-1"> = </span><span class="hl-0">await</span><span class="hl-1"> </span><span class="hl-6">createLibp2p</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-2">transports:</span><span class="hl-1"> [</span><br/><span class="hl-1"> </span><span class="hl-6">websockets</span><span class="hl-1">()</span><br/><span class="hl-1"> ], </span><span class="hl-7">// Any libp2p transport(s) can be used</span><br/><span class="hl-1"> </span><span class="hl-2">streamMuxers:</span><span class="hl-1"> [</span><br/><span class="hl-1"> </span><span class="hl-6">yamux</span><span class="hl-1">()</span><br/><span class="hl-1"> ],</span><br/><span class="hl-1"> </span><span class="hl-2">connectionEncryption:</span><span class="hl-1"> [</span><br/><span class="hl-1"> </span><span class="hl-6">noise</span><span class="hl-1">()</span><br/><span class="hl-1"> ],</span><br/><span class="hl-1"> </span><span class="hl-2">peerDiscovery:</span><span class="hl-1"> [</span><br/><span class="hl-1"> </span><span class="hl-6">pubsubPeerDiscovery</span><span class="hl-1">()</span><br/><span class="hl-1"> ],</span><br/><span class="hl-1"> </span><span class="hl-2">services:</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-2">pubsub:</span><span class="hl-1"> </span><span class="hl-6">gossipsub</span><span class="hl-1">(),</span><br/><span class="hl-1"> </span><span class="hl-2">identify:</span><span class="hl-1"> </span><span class="hl-6">identify</span><span class="hl-1">()</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">})</span>
</code><button>Copy</button></pre>
<a id="md:example---customizing-pubsub-peer-discovery" class="tsd-anchor"></a><h2><a href="#md:example---customizing-pubsub-peer-discovery">Example - Customizing Pubsub Peer Discovery</a></h2><p>There are a few options you can use to customize <code>Pubsub Peer Discovery</code>. You can see the detailed <a href="#md:options">options</a> below.</p>
<pre><code class="language-js"><span class="hl-7">// ... Other imports from above</span><br/><span class="hl-0">import</span><span class="hl-1"> </span><span class="hl-2">PubSubPeerDiscovery</span><span class="hl-1"> </span><span class="hl-0">from</span><span class="hl-1"> </span><span class="hl-3">&#39;@libp2p/pubsub-peer-discovery&#39;</span><br/><br/><span class="hl-7">// Custom topics</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-5">topics</span><span class="hl-1"> = [</span><br/><span class="hl-1"> </span><span class="hl-3">`myApp._peer-discovery._p2p._pubsub`</span><span class="hl-1">, </span><span class="hl-7">// It&#39;s recommended but not required to extend the global space</span><br/><span class="hl-1"> </span><span class="hl-3">&#39;_peer-discovery._p2p._pubsub&#39;</span><span class="hl-1"> </span><span class="hl-7">// Include if you want to participate in the global space</span><br/><span class="hl-1">]</span><br/><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-5">node</span><span class="hl-1"> = </span><span class="hl-0">await</span><span class="hl-1"> </span><span class="hl-6">createLibp2p</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-7">// ...</span><br/><span class="hl-1"> </span><span class="hl-2">peerDiscovery:</span><span class="hl-1"> [</span><br/><span class="hl-1"> </span><span class="hl-6">pubsubPeerDiscovery</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-2">interval:</span><span class="hl-1"> </span><span class="hl-8">10000</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-2">topics:</span><span class="hl-1"> </span><span class="hl-2">topics</span><span class="hl-1">, </span><span class="hl-7">// defaults to [&#39;_peer-discovery._p2p._pubsub&#39;]</span><br/><span class="hl-1"> </span><span class="hl-2">listenOnly:</span><span class="hl-1"> </span><span class="hl-4">false</span><br/><span class="hl-1"> })</span><br/><span class="hl-1"> ]</span><br/><span class="hl-1">})</span>
Expand Down
Loading

0 comments on commit 7ba656f

Please sign in to comment.