js-libp2p/index.html
2020-04-24 17:38:45 +02:00

12257 lines
253 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset='utf-8'>
<title>libp2p 0.27.7 | Documentation</title>
<meta name='description' content='JavaScript implementation of libp2p, a modular peer to peer network stack'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<link href='assets/bass.css' rel='stylesheet'>
<link href='assets/style.css' rel='stylesheet'>
<link href='assets/github.css' rel='stylesheet'>
<link href='assets/split.css' rel='stylesheet'>
</head>
<body class='documentation m0'>
<div class='flex'>
<div id='split-left' class='overflow-auto fs0 height-viewport-100'>
<div class='py1 px2'>
<h3 class='mb0 no-anchor'>libp2p</h3>
<div class='mb1'><code>0.27.7</code></div>
<input
placeholder='Filter'
id='filter-input'
class='col12 block input'
spellcheck='false'
autocapitalize='off'
autocorrect='off'
type='text' />
<div id='toc'>
<ul class='list-reset h5 py1-ul'>
<li><a
href='#intro'
class="h5 bold black caps">
Intro
</a>
</li>
<li><a
href='#libp2p'
class=" toggle-sibling">
Libp2p
<span class='icon'></span>
</a>
<div class='toggle-target display-none'>
<ul class='list-reset py1-ul pl1'>
<li class='h5'><span>Static members</span></li>
<li><a
href='#libp2pcreate'
class='regular pre-open'>
.create
</a></li>
</ul>
<ul class='list-reset py1-ul pl1'>
<li class='h5'><span>Instance members</span></li>
<li><a
href='#libp2pemit'
class='regular pre-open'>
#emit
</a></li>
<li><a
href='#libp2pstart'
class='regular pre-open'>
#start
</a></li>
<li><a
href='#libp2pstop'
class='regular pre-open'>
#stop
</a></li>
<li><a
href='#libp2pconnections'
class='regular pre-open'>
#connections
</a></li>
<li><a
href='#libp2pdial'
class='regular pre-open'>
#dial
</a></li>
<li><a
href='#libp2pdialprotocol'
class='regular pre-open'>
#dialProtocol
</a></li>
<li><a
href='#libp2phangup'
class='regular pre-open'>
#hangUp
</a></li>
<li><a
href='#libp2pping'
class='regular pre-open'>
#ping
</a></li>
<li><a
href='#libp2phandle'
class='regular pre-open'>
#handle
</a></li>
<li><a
href='#libp2punhandle'
class='regular pre-open'>
#unhandle
</a></li>
</ul>
</div>
</li>
<li><a
href='#findpeer'
class="">
findPeer
</a>
</li>
<li><a
href='#findproviders'
class="">
findProviders
</a>
</li>
<li><a
href='#provide'
class="">
provide
</a>
</li>
<li><a
href='#put'
class="">
put
</a>
</li>
<li><a
href='#get'
class="">
get
</a>
</li>
<li><a
href='#getmany'
class="">
getMany
</a>
</li>
<li><a
href='#subscribe'
class="">
subscribe
</a>
</li>
<li><a
href='#unsubscribe'
class="">
unsubscribe
</a>
</li>
<li><a
href='#publish'
class="">
publish
</a>
</li>
<li><a
href='#gettopics'
class="">
getTopics
</a>
</li>
<li><a
href='#getsubscribers'
class="">
getSubscribers
</a>
</li>
<li><a
href='#getpeerinfo'
class="">
getPeerInfo
</a>
</li>
<li><a
href='#getpeerinforemote'
class="">
getPeerInfoRemote
</a>
</li>
<li><a
href='#constructor'
class="">
constructor
</a>
</li>
<li><a
href='#start'
class="">
start
</a>
</li>
<li><a
href='#stop'
class="">
stop
</a>
</li>
<li><a
href='#setpeervalue'
class="">
setPeerValue
</a>
</li>
<li><a
href='#onconnect'
class="">
onConnect
</a>
</li>
<li><a
href='#ondisconnect'
class="">
onDisconnect
</a>
</li>
<li><a
href='#globalthis'
class="">
globalThis
</a>
</li>
<li><a
href='#summaryobject'
class="">
SummaryObject
</a>
</li>
<li><a
href='#latencymonitor'
class=" toggle-sibling">
LatencyMonitor
<span class='icon'></span>
</a>
<div class='toggle-target display-none'>
<ul class='list-reset py1-ul pl1'>
<li class='h5'><span>Instance members</span></li>
<li><a
href='#latencymonitorgetsummary'
class='regular pre-open'>
#getSummary
</a></li>
</ul>
</div>
</li>
<li><a
href='#'
class="">
</a>
</li>
<li><a
href='#visibilitychangeemitter'
class="">
VisibilityChangeEmitter
</a>
</li>
<li><a
href='#isvisible'
class="">
isVisible
</a>
</li>
<li><a
href='#constructor'
class="">
constructor
</a>
</li>
<li><a
href='#dial'
class="">
dial
</a>
</li>
<li><a
href='#createlistener'
class="">
createListener
</a>
</li>
<li><a
href='#filter'
class="">
filter
</a>
</li>
<li><a
href='#index'
class=" toggle-sibling">
index
<span class='icon'></span>
</a>
<div class='toggle-target display-none'>
<ul class='list-reset py1-ul pl1'>
<li class='h5'><span>Static members</span></li>
<li><a
href='#indexmulticodecs'
class='regular pre-open'>
.multicodecs
</a></li>
</ul>
</div>
</li>
<li><a
href='#listener'
class=" toggle-sibling">
listener
<span class='icon'></span>
</a>
<div class='toggle-target display-none'>
<ul class='list-reset py1-ul pl1'>
<li class='h5'><span>Static members</span></li>
<li><a
href='#listenerlisten'
class='regular pre-open'>
.listen
</a></li>
<li><a
href='#listenerclose'
class='regular pre-open'>
.close
</a></li>
<li><a
href='#listenergetaddrs'
class='regular pre-open'>
.getAddrs
</a></li>
</ul>
</div>
</li>
<li><a
href='#hop'
class="">
hop
</a>
</li>
<li><a
href='#writeresponse'
class="">
writeResponse
</a>
</li>
<li><a
href='#validateaddrs'
class="">
validateAddrs
</a>
</li>
<li><a
href='#constructor'
class="">
constructor
</a>
</li>
<li><a
href='#read'
class="">
read
</a>
</li>
<li><a
href='#write'
class="">
write
</a>
</li>
<li><a
href='#rest'
class="">
rest
</a>
</li>
<li><a
href='#close'
class="">
close
</a>
</li>
<li><a
href='#constructor'
class="">
constructor
</a>
</li>
<li><a
href='#destroy'
class="">
destroy
</a>
</li>
<li><a
href='#connecttopeer'
class="">
connectToPeer
</a>
</li>
<li><a
href='#_createdialtarget'
class="">
_createDialTarget
</a>
</li>
<li><a
href='#_creatependingdial'
class="">
_createPendingDial
</a>
</li>
<li><a
href='#getdialable'
class="">
getDialable
</a>
</li>
<li><a
href='#constructor'
class="">
constructor
</a>
</li>
<li><a
href='#run'
class="">
run
</a>
</li>
<li><a
href='#constructor'
class="">
constructor
</a>
</li>
<li><a
href='#start'
class="">
start
</a>
</li>
<li><a
href='#stop'
class="">
stop
</a>
</li>
<li><a
href='#global'
class="">
global
</a>
</li>
<li><a
href='#peers'
class="">
peers
</a>
</li>
<li><a
href='#forpeer'
class="">
forPeer
</a>
</li>
<li><a
href='#protocols'
class="">
protocols
</a>
</li>
<li><a
href='#forprotocol'
class="">
forProtocol
</a>
</li>
<li><a
href='#onpeerdisconnected'
class="">
onPeerDisconnected
</a>
</li>
<li><a
href='#updateplaceholder'
class="">
updatePlaceholder
</a>
</li>
<li><a
href='#trackstream'
class="">
trackStream
</a>
</li>
<li><a
href='#mergestats'
class="">
mergeStats
</a>
</li>
<li><a
href='#old-peers'
class="">
old-peers
</a>
</li>
<li><a
href='#stats'
class=" toggle-sibling">
Stats
<span class='icon'></span>
</a>
<div class='toggle-target display-none'>
<ul class='list-reset py1-ul pl1'>
<li class='h5'><span>Instance members</span></li>
<li><a
href='#statsstart'
class='regular pre-open'>
#start
</a></li>
<li><a
href='#statsstop'
class='regular pre-open'>
#stop
</a></li>
<li><a
href='#statssnapshot'
class='regular pre-open'>
#snapshot
</a></li>
<li><a
href='#statsmovingaverages'
class='regular pre-open'>
#movingAverages
</a></li>
<li><a
href='#statstojson'
class='regular pre-open'>
#toJSON
</a></li>
<li><a
href='#statspush'
class='regular pre-open'>
#push
</a></li>
</ul>
</div>
</li>
<li><a
href='#constructor'
class="">
constructor
</a>
</li>
<li><a
href='#add'
class="">
add
</a>
</li>
<li><a
href='#close'
class="">
close
</a>
</li>
<li><a
href='#dial'
class="">
dial
</a>
</li>
<li><a
href='#getaddrs'
class="">
getAddrs
</a>
</li>
<li><a
href='#gettransports'
class="">
getTransports
</a>
</li>
<li><a
href='#transportformultiaddr'
class="">
transportForMultiaddr
</a>
</li>
<li><a
href='#listen'
class="">
listen
</a>
</li>
<li><a
href='#remove'
class="">
remove
</a>
</li>
<li><a
href='#removeall'
class="">
removeAll
</a>
</li>
<li><a
href='#upgrader'
class=" toggle-sibling">
Upgrader
<span class='icon'></span>
</a>
<div class='toggle-target display-none'>
<ul class='list-reset py1-ul pl1'>
<li class='h5'><span>Instance members</span></li>
<li><a
href='#upgraderupgradeinbound'
class='regular pre-open'>
#upgradeInbound
</a></li>
<li><a
href='#upgraderupgradeoutbound'
class='regular pre-open'>
#upgradeOutbound
</a></li>
</ul>
</div>
</li>
<li><a
href='#upgrader'
class=" toggle-sibling">
Upgrader
<span class='icon'></span>
</a>
<div class='toggle-target display-none'>
<ul class='list-reset py1-ul pl1'>
<li class='h5'><span>Instance members</span></li>
<li><a
href='#upgraderupgradeinbound'
class='regular pre-open'>
#upgradeInbound
</a></li>
<li><a
href='#upgraderupgradeoutbound'
class='regular pre-open'>
#upgradeOutbound
</a></li>
</ul>
</div>
</li>
<li><a
href='#peerstore'
class=" toggle-sibling">
PeerStore
<span class='icon'></span>
</a>
<div class='toggle-target display-none'>
<ul class='list-reset py1-ul pl1'>
<li class='h5'><span>Instance members</span></li>
<li><a
href='#peerstorepeers'
class='regular pre-open'>
#peers
</a></li>
<li><a
href='#peerstoreput'
class='regular pre-open'>
#put
</a></li>
<li><a
href='#peerstoreadd'
class='regular pre-open'>
#add
</a></li>
<li><a
href='#peerstoreupdate'
class='regular pre-open'>
#update
</a></li>
<li><a
href='#peerstoreget'
class='regular pre-open'>
#get
</a></li>
<li><a
href='#peerstorehas'
class='regular pre-open'>
#has
</a></li>
<li><a
href='#peerstoreremove'
class='regular pre-open'>
#remove
</a></li>
<li><a
href='#peerstorereplace'
class='regular pre-open'>
#replace
</a></li>
<li><a
href='#peerstoremultiaddrsforpeer'
class='regular pre-open'>
#multiaddrsForPeer
</a></li>
</ul>
</div>
</li>
<li><a
href='#registrar'
class=" toggle-sibling">
Registrar
<span class='icon'></span>
</a>
<div class='toggle-target display-none'>
<ul class='list-reset py1-ul pl1'>
<li class='h5'><span>Instance members</span></li>
<li><a
href='#registrarconnections'
class='regular pre-open'>
#connections
</a></li>
<li><a
href='#registrartopologies'
class='regular pre-open'>
#topologies
</a></li>
<li><a
href='#registrarclose'
class='regular pre-open'>
#close
</a></li>
<li><a
href='#registraronconnect'
class='regular pre-open'>
#onConnect
</a></li>
<li><a
href='#registrarondisconnect'
class='regular pre-open'>
#onDisconnect
</a></li>
<li><a
href='#registrargetconnection'
class='regular pre-open'>
#getConnection
</a></li>
<li><a
href='#registrarregister'
class='regular pre-open'>
#register
</a></li>
<li><a
href='#registrarunregister'
class='regular pre-open'>
#unregister
</a></li>
</ul>
</div>
</li>
<li><a
href='#ping'
class="">
ping
</a>
</li>
<li><a
href='#mount'
class="">
mount
</a>
</li>
<li><a
href='#unmount'
class="">
unmount
</a>
</li>
<li><a
href='#constructor'
class="">
constructor
</a>
</li>
<li><a
href='#registrar'
class="">
registrar
</a>
</li>
<li><a
href='#peerinfo'
class="">
peerInfo
</a>
</li>
<li><a
href='#push'
class="">
push
</a>
</li>
<li><a
href='#pushtopeerstore'
class="">
pushToPeerStore
</a>
</li>
<li><a
href='#identify'
class="">
identify
</a>
</li>
<li><a
href='#handlemessage'
class="">
handleMessage
</a>
</li>
<li><a
href='#updatepeeraddresses'
class="">
updatePeerAddresses
</a>
</li>
<li><a
href='#updatepeerprotocols'
class="">
updatePeerProtocols
</a>
</li>
<li><a
href='#getcleanmultiaddr'
class="">
getCleanMultiaddr
</a>
</li>
</ul>
</div>
<div class='mt1 h6 quiet'>
<a href='https://documentation.js.org/reading-documentation.html'>Need help reading this?</a>
</div>
</div>
</div>
<div id='split-right' class='relative overflow-auto height-viewport-100'>
<div class='keyline-top-not py2'><section class='py2 clearfix'>
<h2 id='intro' class='mt0'>
Intro
</h2>
<p>Installable via <code>npm install --save libp2p</code>, it can also be used directly in the browser.</p>
<h2>Download</h2>
<p>The source is available for download from <a href="https://github.com/libp2p/js-libp2p.git">GitHub</a>. Alternatively, you can install using npm:</p>
<pre class='hljs'>$ npm install --save libp2p</pre>
<p>You can then <code>require()</code> libp2p as normal:</p>
<pre class='hljs'><span class="hljs-keyword">const</span> libp2P = <span class="hljs-built_in">require</span>(<span class="hljs-string">'libp2p'</span>)</pre>
<h2>In the Browser</h2>
<p><code>libp2p</code> should work in any ECMAScript 2018 environment out of the box.</p>
<p>Usage:</p>
<pre class='hljs'><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text/javascript"</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"index.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></pre>
<p>The portable versions of <code>libp2p</code>, including <code>index.js</code> and <code>index.min.js</code>, are included in the <code>/dist</code> folder. <code>libp2p</code> can also be found on <a href="https://unpkg.com">unpkg.com</a> under</p>
<ul>
<li><a href="https://unpkg.com/libp2p/dist/index.min.js">https://unpkg.com/libp2p/dist/index.min.js</a></li>
<li><a href="https://unpkg.com/libp2p/dist/index.js">https://unpkg.com/libp2p/dist/index.js</a></li>
</ul>
</section></div>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='libp2p'>
Libp2p
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/index.js#L38-L513'>
<span>src/index.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>new Libp2p(_options: any)</div>
<p>
Extends
EventEmitter
</p>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>_options</span> <code class='quiet'>(any)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Static Members</div>
<div class="clearfix">
<div class='border-bottom' id='libp2pcreate'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>create(options)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/index.js#L521-L530'>
<span>src/index.js</span>
</a>
</div>
<p>Like <code>new Libp2p(options)</code> except it will create a <code>PeerInfo</code>
instance if one is not provided in options.</p>
<div class='pre p1 fill-light mt0'>create(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>): <a href="#libp2p">Libp2p</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>
= <code>{}</code>)</code>
Libp2p configuration options
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="#libp2p">Libp2p</a></code>:
</section>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
<div class="clearfix">
<div class='border-bottom' id='libp2pemit'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>emit(eventName, args)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/index.js#L186-L192'>
<span>src/index.js</span>
</a>
</div>
<p>Overrides EventEmitter.emit to conditionally emit errors
if there is a handler. If not, errors will be logged.</p>
<div class='pre p1 fill-light mt0'>emit(eventName: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, args: ...any): void</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>eventName</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>args</span> <code class='quiet'>(...any)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
</div>
</div>
<div class='border-bottom' id='libp2pstart'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>start()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/index.js#L199-L211'>
<span>src/index.js</span>
</a>
</div>
<p>Starts the libp2p node and all its subsystems</p>
<div class='pre p1 fill-light mt0'>start(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></code>:
</section>
</div>
</div>
<div class='border-bottom' id='libp2pstop'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>stop()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/index.js#L218-L249'>
<span>src/index.js</span>
</a>
</div>
<p>Stop the libp2p node by closing its listeners and open connections</p>
<div class='pre p1 fill-light mt0'>stop(): void</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
</div>
</div>
<div class='border-bottom' id='libp2pconnections'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>connections</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/index.js#L260-L262'>
<span>src/index.js</span>
</a>
</div>
<p>Gets a Map of the current connections. The keys are the stringified
<code>PeerId</code> of the peer. The value is an array of Connections to that peer.</p>
<div class='pre p1 fill-light mt0'>connections</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map">Map</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Connection>></code>:
</section>
</div>
</div>
<div class='border-bottom' id='libp2pdial'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>dial(peer, options)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/index.js#L273-L275'>
<span>src/index.js</span>
</a>
</div>
<p>Dials to the provided peer. If successful, the <code>PeerInfo</code> of the
peer will be added to the nodes <code>peerStore</code></p>
<div class='pre p1 fill-light mt0'>dial(peer: (PeerInfo | PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>), options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peer</span> <code class='quiet'>((PeerInfo | PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
The peer to dial
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.signal</span> <code class='quiet'>AbortSignal?</code>
</td>
<td class='break-word'><span></span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></code>:
</section>
</div>
</div>
<div class='border-bottom' id='libp2pdialprotocol'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>dialProtocol(peer, protocols, options)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/index.js#L289-L307'>
<span>src/index.js</span>
</a>
</div>
<p>Dials to the provided peer and handshakes with the given protocol.
If successful, the <code>PeerInfo</code> of the peer will be added to the nodes <code>peerStore</code>,
and the <code>Connection</code> will be sent in the callback</p>
<div class='pre p1 fill-light mt0'>dialProtocol(peer: (PeerInfo | PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>), protocols: (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>), options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;(Connection | any)></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peer</span> <code class='quiet'>((PeerInfo | PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
The peer to dial
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>protocols</span> <code class='quiet'>((<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.signal</span> <code class='quiet'>AbortSignal?</code>
</td>
<td class='break-word'><span></span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;(Connection | any)></code>:
</section>
</div>
</div>
<div class='border-bottom' id='libp2phangup'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>hangUp(peer)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/index.js#L315-L329'>
<span>src/index.js</span>
</a>
</div>
<p>Disconnects all connections to the given <code>peer</code></p>
<div class='pre p1 fill-light mt0'>hangUp(peer: (PeerInfo | PeerId | multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peer</span> <code class='quiet'>((PeerInfo | PeerId | multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
the peer to close connections to
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></code>:
</section>
</div>
</div>
<div class='border-bottom' id='libp2pping'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>ping(peer)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/index.js#L336-L340'>
<span>src/index.js</span>
</a>
</div>
<p>Pings the given peer</p>
<div class='pre p1 fill-light mt0'>ping(peer: (PeerInfo | PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peer</span> <code class='quiet'>((PeerInfo | PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
The peer to ping
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>></code>:
</section>
</div>
</div>
<div class='border-bottom' id='libp2phandle'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>handle(protocols, handler)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/index.js#L347-L357'>
<span>src/index.js</span>
</a>
</div>
<p>Registers the <code>handler</code> for each protocol</p>
<div class='pre p1 fill-light mt0'>handle(protocols: (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>), handler: function ({connection: any, stream: any, protocol: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}))</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>protocols</span> <code class='quiet'>((<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>handler</span> <code class='quiet'>(function ({connection: any, stream: any, protocol: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}))</code>
</div>
</div>
</div>
</section>
</div>
</div>
<div class='border-bottom' id='libp2punhandle'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>unhandle(protocols)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/index.js#L364-L374'>
<span>src/index.js</span>
</a>
</div>
<p>Removes the handler for each protocol. The protocol
will no longer be supported on streams.</p>
<div class='pre p1 fill-light mt0'>unhandle(protocols: (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>protocols</span> <code class='quiet'>((<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
</div>
</div>
</div>
</section>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='findpeer'>
findPeer
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/peer-routing.js#L23-L38'>
<span>src/peer-routing.js</span>
</a>
</div>
<p>Iterates over all peer routers in series to find the given peer.</p>
<div class='pre p1 fill-light mt0'>findPeer(id: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;PeerInfo></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>id</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
The id of the peer to find
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.timeout</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>?</code>
</td>
<td class='break-word'><span>How long the query should run
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;PeerInfo></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='findproviders'>
findProviders
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/content-routing.js#L29-L48'>
<span>src/content-routing.js</span>
</a>
</div>
<p>Iterates over all content routers in series to find providers of the given key.
Once a content router succeeds, iteration will stop.</p>
<div class='pre p1 fill-light mt0'>findProviders(key: CID, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?): AsyncIterable&#x3C;PeerInfo></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>key</span> <code class='quiet'>(CID)</code>
The CID key of the content to find
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.timeout</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>?</code>
</td>
<td class='break-word'><span>How long the query should run
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.maxNumProviders</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>?</code>
</td>
<td class='break-word'><span>maximum number of providers to find
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>AsyncIterable&#x3C;PeerInfo></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='provide'>
provide
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/content-routing.js#L57-L63'>
<span>src/content-routing.js</span>
</a>
</div>
<p>Iterates over all content routers in parallel to notify it is
a provider of the given key.</p>
<div class='pre p1 fill-light mt0'>provide(key: CID): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>key</span> <code class='quiet'>(CID)</code>
The CID key of the content to find
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='put'>
put
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/content-routing.js#L73-L79'>
<span>src/content-routing.js</span>
</a>
</div>
<p>Store the given key/value pair in the DHT.</p>
<div class='pre p1 fill-light mt0'>put(key: <a href="https://nodejs.org/api/buffer.html">Buffer</a>, value: <a href="https://nodejs.org/api/buffer.html">Buffer</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>key</span> <code class='quiet'>(<a href="https://nodejs.org/api/buffer.html">Buffer</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>value</span> <code class='quiet'>(<a href="https://nodejs.org/api/buffer.html">Buffer</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?)</code>
put options
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.minPeers</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>?</code>
</td>
<td class='break-word'><span>minimum number of peers required to successfully put
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='get'>
get
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/content-routing.js#L89-L95'>
<span>src/content-routing.js</span>
</a>
</div>
<p>Get the value to the given key.
Times out after 1 minute by default.</p>
<div class='pre p1 fill-light mt0'>get(key: <a href="https://nodejs.org/api/buffer.html">Buffer</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;{from: PeerId, val: <a href="https://nodejs.org/api/buffer.html">Buffer</a>}></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>key</span> <code class='quiet'>(<a href="https://nodejs.org/api/buffer.html">Buffer</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?)</code>
get options
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.timeout</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>?</code>
</td>
<td class='break-word'><span>optional timeout (default: 60000)
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;{from: PeerId, val: <a href="https://nodejs.org/api/buffer.html">Buffer</a>}></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='getmany'>
getMany
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/content-routing.js#L105-L111'>
<span>src/content-routing.js</span>
</a>
</div>
<p>Get the <code>n</code> values to the given key without sorting.</p>
<div class='pre p1 fill-light mt0'>getMany(key: <a href="https://nodejs.org/api/buffer.html">Buffer</a>, nVals: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;{from: PeerId, val: <a href="https://nodejs.org/api/buffer.html">Buffer</a>}>></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>key</span> <code class='quiet'>(<a href="https://nodejs.org/api/buffer.html">Buffer</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>nVals</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?)</code>
get options
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.timeout</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>?</code>
</td>
<td class='break-word'><span>optional timeout (default: 60000)
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;{from: PeerId, val: <a href="https://nodejs.org/api/buffer.html">Buffer</a>}>></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='subscribe'>
subscribe
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/pubsub.js#L17-L27'>
<span>src/pubsub.js</span>
</a>
</div>
<p>Subscribe the given handler to a pubsub topic</p>
<div class='pre p1 fill-light mt0'>subscribe(topic: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, handler: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">function</a>): void</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>topic</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>handler</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">function</a>)</code>
The handler to subscribe
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='unsubscribe'>
unsubscribe
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/pubsub.js#L34-L48'>
<span>src/pubsub.js</span>
</a>
</div>
<p>Unsubscribes from a pubsub topic</p>
<div class='pre p1 fill-light mt0'>unsubscribe(topic: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, handler: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">function</a>?)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>topic</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>handler</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">function</a>?)</code>
The handler to unsubscribe from
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='publish'>
publish
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/pubsub.js#L56-L68'>
<span>src/pubsub.js</span>
</a>
</div>
<p>Publish messages to the given topics.</p>
<div class='pre p1 fill-light mt0'>publish(topic: (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>), data: <a href="https://nodejs.org/api/buffer.html">Buffer</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>topic</span> <code class='quiet'>((<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>data</span> <code class='quiet'>(<a href="https://nodejs.org/api/buffer.html">Buffer</a>)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='gettopics'>
getTopics
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/pubsub.js#L74-L80'>
<span>src/pubsub.js</span>
</a>
</div>
<p>Get a list of topics the node is subscribed to.</p>
<div class='pre p1 fill-light mt0'>getTopics(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>></div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>></code>:
topics
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='getsubscribers'>
getSubscribers
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/pubsub.js#L87-L93'>
<span>src/pubsub.js</span>
</a>
</div>
<p>Get a list of the peer-ids that are subscribed to one topic.</p>
<div class='pre p1 fill-light mt0'>getSubscribers(topic: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>topic</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='getpeerinfo'>
getPeerInfo
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/get-peer-info.js#L17-L42'>
<span>src/get-peer-info.js</span>
</a>
</div>
<p>Converts the given <code>peer</code> to a <code>PeerInfo</code> instance.
The <code>PeerStore</code> will be checked for the resulting peer, and
the peer will be updated in the <code>PeerStore</code>.</p>
<div class='pre p1 fill-light mt0'>getPeerInfo(peer: (PeerInfo | PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>), peerStore: <a href="#peerstore">PeerStore</a>): PeerInfo</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peer</span> <code class='quiet'>((PeerInfo | PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerStore</span> <code class='quiet'>(<a href="#peerstore">PeerStore</a>)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>PeerInfo</code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='getpeerinforemote'>
getPeerInfoRemote
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/get-peer-info.js#L53-L68'>
<span>src/get-peer-info.js</span>
</a>
</div>
<p>If <code>getPeerInfo</code> does not return a peer with multiaddrs,
the <code>libp2p</code> PeerRouter will be used to attempt to find the peer.</p>
<div class='pre p1 fill-light mt0'>getPeerInfoRemote(peer: (PeerInfo | PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>), libp2p: <a href="#libp2p">Libp2p</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;PeerInfo></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peer</span> <code class='quiet'>((PeerInfo | PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>libp2p</span> <code class='quiet'>(<a href="#libp2p">Libp2p</a>)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;PeerInfo></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='constructor'>
constructor
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/connection-manager/index.js#L40-L57'>
<span>src/connection-manager/index.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>new constructor(libp2p: <a href="#libp2p">Libp2p</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>libp2p</span> <code class='quiet'>(<a href="#libp2p">Libp2p</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.maxConnections</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
</td>
<td class='break-word'><span>The maximum number of connections allowed. Default=Infinity
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.minConnections</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
</td>
<td class='break-word'><span>The minimum number of connections to avoid pruning. Default=0
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.maxData</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
</td>
<td class='break-word'><span>The max data (in and out), per average interval to allow. Default=Infinity
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.maxSentData</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
</td>
<td class='break-word'><span>The max outgoing data, per average interval to allow. Default=Infinity
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.maxReceivedData</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
</td>
<td class='break-word'><span>The max incoming data, per average interval to allow.. Default=Infinity
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.maxEventLoopDelay</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
</td>
<td class='break-word'><span>The upper limit the event loop can take to run. Default=Infinity
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.pollInterval</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
</td>
<td class='break-word'><span>How often, in milliseconds, metrics and latency should be checked. Default=2000
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.movingAverageInterval</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
</td>
<td class='break-word'><span>How often, in milliseconds, to compute averages. Default=60000
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.defaultPeerValue</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
</td>
<td class='break-word'><span>The value of the peer. Default=1
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='start'>
start
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/connection-manager/index.js#L63-L76'>
<span>src/connection-manager/index.js</span>
</a>
</div>
<p>Starts the Connection Manager. If Metrics are not enabled on libp2p
only event loop and connection limits will be monitored.</p>
<div class='pre p1 fill-light mt0'>start()</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='stop'>
stop
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/connection-manager/index.js#L81-L85'>
<span>src/connection-manager/index.js</span>
</a>
</div>
<p>Stops the Connection Manager</p>
<div class='pre p1 fill-light mt0'>stop()</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='setpeervalue'>
setPeerValue
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/connection-manager/index.js#L93-L101'>
<span>src/connection-manager/index.js</span>
</a>
</div>
<p>Sets the value of the given peer. Peers with lower values
will be disconnected first.</p>
<div class='pre p1 fill-light mt0'>setPeerValue(peerId: PeerId, value: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>value</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)</code>
A number between 0 and 1
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='onconnect'>
onConnect
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/connection-manager/index.js#L124-L131'>
<span>src/connection-manager/index.js</span>
</a>
</div>
<p>Tracks the incoming connection and check the connection limit</p>
<div class='pre p1 fill-light mt0'>onConnect(connection: Connection)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>connection</span> <code class='quiet'>(Connection)</code>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='ondisconnect'>
onDisconnect
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/connection-manager/index.js#L137-L140'>
<span>src/connection-manager/index.js</span>
</a>
</div>
<p>Removes the connection from tracking</p>
<div class='pre p1 fill-light mt0'>onDisconnect(connection: Connection)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>connection</span> <code class='quiet'>(Connection)</code>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='globalthis'>
globalThis
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/connection-manager/latency-monitor.js#L8-L8'>
<span>src/connection-manager/latency-monitor.js</span>
</a>
</div>
<p>This code is based on <code>latency-monitor</code> (<a href="https://github.com/mlucool/latency-monitor">https://github.com/mlucool/latency-monitor</a>) by <code>mlucool</code> (<a href="https://github.com/mlucool">https://github.com/mlucool</a>), available under Apache License 2.0 (<a href="https://github.com/mlucool/latency-monitor/blob/master/LICENSE">https://github.com/mlucool/latency-monitor/blob/master/LICENSE</a>)</p>
<div class='pre p1 fill-light mt0'>globalThis</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='summaryobject'>
SummaryObject
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/connection-manager/latency-monitor.js#L13-L20'>
<span>src/connection-manager/latency-monitor.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>SummaryObject</div>
<p>
Type:
<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>
</p>
<div class='py1 quiet mt1 prose-big'>Properties</div>
<div>
<div class='space-bottom0'>
<span class='code bold'>events</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>)</code>
: How many events were called
</div>
<div class='space-bottom0'>
<span class='code bold'>minMS</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>)</code>
: What was the min time for a cb to be called
</div>
<div class='space-bottom0'>
<span class='code bold'>maxMS</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>)</code>
: What was the max time for a cb to be called
</div>
<div class='space-bottom0'>
<span class='code bold'>avgMs</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>)</code>
: What was the average time for a cb to be called
</div>
<div class='space-bottom0'>
<span class='code bold'>lengthMs</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>)</code>
: How long this interval was in ms
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='latencymonitor'>
LatencyMonitor
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/connection-manager/latency-monitor.js#L38-L240'>
<span>src/connection-manager/latency-monitor.js</span>
</a>
</div>
<p>A class to monitor latency of any async function which works in a browser or node. This works by periodically calling
the asyncTestFn and timing how long it takes the callback to be called. It can also periodically emit stats about this.
This can be disabled and stats can be pulled via setting dataEmitIntervalMs = 0.</p>
<p>The default implementation is an event loop latency monitor. This works by firing periodic events into the event loop
and timing how long it takes to get back.</p>
<div class='pre p1 fill-light mt0'>new LatencyMonitor($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, latencyCheckIntervalMs: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>, dataEmitIntervalMs: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>, asyncTestFn: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">function</a>?, latencyRandomPercentage: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>)</div>
<p>
Extends
EventEmitter
</p>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>
= <code>{}</code>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>$0.latencyCheckIntervalMs</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.dataEmitIntervalMs</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.asyncTestFn</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.latencyRandomPercentage</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
</tbody>
</table>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>latencyCheckIntervalMs</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>
= <code>500</code>)</code>
How often to add a latency check event (ms)
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>dataEmitIntervalMs</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>
= <code>5000</code>)</code>
How often to summarize latency check events. null or 0 disables event firing
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>asyncTestFn</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">function</a>?)</code>
What cb-style async function to use
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>latencyRandomPercentage</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>
= <code>5</code>)</code>
What percent (+/-) of latencyCheckIntervalMs should we randomly use? This helps avoid alignment to other events.
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Example</div>
<pre class='p1 overflow-auto round fill-light'><span class="hljs-keyword">const</span> monitor = <span class="hljs-keyword">new</span> LatencyMonitor();
monitor.on(<span class="hljs-string">'data'</span>, (summary) =&gt; <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Event Loop Latency: %O'</span>, summary));</pre>
<pre class='p1 overflow-auto round fill-light'><span class="hljs-keyword">const</span> monitor = <span class="hljs-keyword">new</span> LatencyMonitor({<span class="hljs-attr">latencyCheckIntervalMs</span>: <span class="hljs-number">1000</span>, <span class="hljs-attr">dataEmitIntervalMs</span>: <span class="hljs-number">60000</span>, <span class="hljs-attr">asyncTestFn</span>:ping});
monitor.on(<span class="hljs-string">'data'</span>, (summary) =&gt; <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Ping Pong Latency: %O'</span>, summary));</pre>
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
<div class="clearfix">
<div class='border-bottom' id='latencymonitorgetsummary'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>getSummary()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/connection-manager/latency-monitor.js#L157-L173'>
<span>src/connection-manager/latency-monitor.js</span>
</a>
</div>
<p>Calling this function will end the collection period. If a timing event was already fired and somewhere in the queue,
it will not count for this time period</p>
<div class='pre p1 fill-light mt0'>getSummary(): <a href="#summaryobject">SummaryObject</a></div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="#summaryobject">SummaryObject</a></code>:
</section>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id=''>
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/connection-manager/visibility-change-emitter.js#L6-L6'>
<span>src/connection-manager/visibility-change-emitter.js</span>
</a>
</div>
<p>This code is based on <code>latency-monitor</code> (<a href="https://github.com/mlucool/latency-monitor">https://github.com/mlucool/latency-monitor</a>) by <code>mlucool</code> (<a href="https://github.com/mlucool">https://github.com/mlucool</a>), available under Apache License 2.0 (<a href="https://github.com/mlucool/latency-monitor/blob/master/LICENSE">https://github.com/mlucool/latency-monitor/blob/master/LICENSE</a>)</p>
<div class='pre p1 fill-light mt0'></div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='visibilitychangeemitter'>
VisibilityChangeEmitter
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/connection-manager/visibility-change-emitter.js#L35-L118'>
<span>src/connection-manager/visibility-change-emitter.js</span>
</a>
</div>
<p>Listen to page visibility change events (i.e. when the page is focused / blurred) by an event emitter.</p>
<p>Warning: This does not work on all browsers, but should work on all modern browsers</p>
<div class='pre p1 fill-light mt0'>new VisibilityChangeEmitter()</div>
<div class='py1 quiet mt1 prose-big'>Example</div>
<pre class='p1 overflow-auto round fill-light'><span class="hljs-keyword">const</span> myVisibilityEmitter = <span class="hljs-keyword">new</span> VisibilityChangeEmitter();
myVisibilityEmitter.on(<span class="hljs-string">'visibilityChange'</span>, (pageInFocus) =&gt; {
<span class="hljs-keyword">if</span> ( pageInFocus ){
<span class="hljs-comment">// Page is in focus</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'In focus'</span>);
}
<span class="hljs-keyword">else</span> {
<span class="hljs-comment">// Page is blurred</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Out of focus'</span>);
}
});
<span class="hljs-comment">// To access the visibility state directly, call:</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Am I focused now? '</span> + myVisibilityEmitter.isVisible());</pre>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='isvisible'>
isVisible
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/connection-manager/visibility-change-emitter.js#L97-L103'>
<span>src/connection-manager/visibility-change-emitter.js</span>
</a>
</div>
<p>The function returns <code>true</code> if the page is visible or <code>false</code> if the page is not visible and
<code>undefined</code> if the page visibility API is not supported by the browser.</p>
<div class='pre p1 fill-light mt0'>isVisible(): (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a> | void)</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a> | void)</code>:
whether the page is now visible or not (undefined is unknown)
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='constructor'>
constructor
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/index.js#L30-L37'>
<span>src/circuit/index.js</span>
</a>
</div>
<p>Creates an instance of Circuit.</p>
<div class='pre p1 fill-light mt0'>new constructor(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.libp2p</span> <code class='quiet'><a href="#libp2p">Libp2p</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.upgrader</span> <code class='quiet'><a href="#upgrader">Upgrader</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='dial'>
dial
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/index.js#L101-L147'>
<span>src/circuit/index.js</span>
</a>
</div>
<p>Dial a peer over a relay</p>
<div class='pre p1 fill-light mt0'>dial(ma: multiaddr, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>): Connection</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>ma</span> <code class='quiet'>(multiaddr)</code>
the multiaddr of the peer to dial
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
dial options
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.signal</span> <code class='quiet'>AbortSignal?</code>
</td>
<td class='break-word'><span>An optional abort signal
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>Connection</code>:
the connection
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='createlistener'>
createListener
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/index.js#L156-L166'>
<span>src/circuit/index.js</span>
</a>
</div>
<p>Create a listener</p>
<div class='pre p1 fill-light mt0'>createListener(options: any, handler: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">Function</a>): <a href="#listener">listener</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(any)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>handler</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">Function</a>)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="#listener">listener</a></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='filter'>
filter
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/index.js#L174-L180'>
<span>src/circuit/index.js</span>
</a>
</div>
<p>Filter check for all Multiaddrs that this transport can dial on</p>
<div class='pre p1 fill-light mt0'>filter(multiaddrs: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>multiaddrs</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr>)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='index'>
index
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/index.js#L186-L186'>
<span>src/circuit/index.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>index</div>
<p>
Type:
Circuit
</p>
<div class='py1 quiet mt1 prose-big'>Static Members</div>
<div class="clearfix">
<div class='border-bottom' id='indexmulticodecs'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>multicodecs</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/identify/index.js#L299-L302'>
<span>src/identify/index.js</span>
</a>
</div>
<p>The protocols the IdentifyService supports</p>
<div class='pre p1 fill-light mt0'>multicodecs</div>
</section>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='listener'>
listener
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/listener.js#L14-L66'>
<span>src/circuit/listener.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>listener(circuit: any): Listener</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>circuit</span> <code class='quiet'>(any)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>Listener</code>:
a transport listener
<div class='py1 quiet mt1 prose-big'>Static Members</div>
<div class="clearfix">
<div class='border-bottom' id='listenerlisten'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>listen(addr)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/listener.js#L24-L32'>
<span>src/circuit/listener.js</span>
</a>
</div>
<p>Add swarm handler and listen for incoming connections</p>
<div class='pre p1 fill-light mt0'>listen(addr: Multiaddr): void</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>addr</span> <code class='quiet'>(Multiaddr)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
</div>
</div>
<div class='border-bottom' id='listenerclose'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>close()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/listener.js#L39-L39'>
<span>src/circuit/listener.js</span>
</a>
</div>
<p>TODO: Remove the peers from our topology</p>
<div class='pre p1 fill-light mt0'>close(): void</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
</div>
</div>
<div class='border-bottom' id='listenergetaddrs'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>getAddrs()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/listener.js#L57-L63'>
<span>src/circuit/listener.js</span>
</a>
</div>
<p>Get fixed up multiaddrs</p>
<p>NOTE: This method will grab the peers multiaddrs and expand them such that:</p>
<p>a) If it's an existing /p2p-circuit address for a specific relay i.e.
<code>/ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit</code> this method will expand the
address to <code>/ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit/ipfs/QmPeer</code> where
<code>QmPeer</code> is this peers id
b) If it's not a /p2p-circuit address, it will encapsulate the address as a /p2p-circuit
addr, such when dialing over a relay with this address, it will create the circuit using
the encapsulated transport address. This is useful when for example, a peer should only
be dialed over TCP rather than any other transport</p>
<div class='pre p1 fill-light mt0'>getAddrs(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr></div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr></code>:
</section>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='hop'>
hop
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/circuit/hop.js#L99-L119'>
<span>src/circuit/circuit/hop.js</span>
</a>
</div>
<p>Performs a HOP request to a relay peer, to request a connection to another
peer. A new, virtual, connection will be created between the two via the relay.</p>
<div class='pre p1 fill-light mt0'>hop(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.connection</span> <code class='quiet'>Connection</code>
</td>
<td class='break-word'><span>Connection to the relay
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.request</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.circuit</span> <code class='quiet'>Circuit</code>
</td>
<td class='break-word'><span></span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='writeresponse'>
writeResponse
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/circuit/utils.js#L12-L17'>
<span>src/circuit/circuit/utils.js</span>
</a>
</div>
<p>Write a response</p>
<div class='pre p1 fill-light mt0'>writeResponse(streamHandler: StreamHandler, status: CircuitRelay.Status)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>streamHandler</span> <code class='quiet'>(StreamHandler)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>status</span> <code class='quiet'>(CircuitRelay.Status)</code>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='validateaddrs'>
validateAddrs
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/circuit/utils.js#L25-L47'>
<span>src/circuit/circuit/utils.js</span>
</a>
</div>
<p>Validate incomming HOP/STOP message</p>
<div class='pre p1 fill-light mt0'>validateAddrs(msg: any, streamHandler: StreamHandler)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>msg</span> <code class='quiet'>(any)</code>
A CircuitRelay unencoded protobuf message
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>streamHandler</span> <code class='quiet'>(StreamHandler)</code>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='constructor'>
constructor
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/circuit/stream-handler.js#L19-L24'>
<span>src/circuit/circuit/stream-handler.js</span>
</a>
</div>
<p>Create a stream handler for connection</p>
<div class='pre p1 fill-light mt0'>constructor(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.stream</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span>A duplex iterable
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.maxLength</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
(default <code>4096</code>)
</td>
<td class='break-word'><span>max bytes length of message
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='read'>
read
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/circuit/stream-handler.js#L31-L42'>
<span>src/circuit/circuit/stream-handler.js</span>
</a>
</div>
<p>Read and decode message</p>
<div class='pre p1 fill-light mt0'>read(): void</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='write'>
write
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/circuit/stream-handler.js#L49-L52'>
<span>src/circuit/circuit/stream-handler.js</span>
</a>
</div>
<p>Encode and write array of buffers</p>
<div class='pre p1 fill-light mt0'>write(msg: any)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>msg</span> <code class='quiet'>(any)</code>
An unencoded CircuitRelay protobuf message
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='rest'>
rest
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/circuit/stream-handler.js#L59-L62'>
<span>src/circuit/circuit/stream-handler.js</span>
</a>
</div>
<p>Return the handshake rest stream and invalidate handler</p>
<div class='pre p1 fill-light mt0'>rest(): any</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>any</code>:
A duplex iterable
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='close'>
close
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/circuit/circuit/stream-handler.js#L74-L77'>
<span>src/circuit/circuit/stream-handler.js</span>
</a>
</div>
<p>Close the stream</p>
<div class='pre p1 fill-light mt0'>close(): void</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='constructor'>
constructor
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/dialer/index.js#L30-L44'>
<span>src/dialer/index.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>new constructor($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>, peerStore: Peerstore)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>$0.transportManager</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.peerStore</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.concurrency</span> <code class='quiet'>any</code>
(default <code>MAX_PARALLEL_DIALS</code>)
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.timeout</span> <code class='quiet'>any</code>
(default <code>DIAL_TIMEOUT</code>)
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.perPeerLimit</span> <code class='quiet'>any</code>
(default <code>MAX_PER_PEER_DIALS</code>)
</td>
<td class='break-word'><span></span></td>
</tr>
</tbody>
</table>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.transportManager</span> <code class='quiet'>TransportManager</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.concurrency</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code>
</td>
<td class='break-word'><span>Number of max concurrent dials. Defaults to
<code>MAX_PARALLEL_DIALS</code>
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.timeout</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code>
</td>
<td class='break-word'><span>How long a dial attempt is allowed to take. Defaults to
<code>DIAL_TIMEOUT</code>
</span></td>
</tr>
</tbody>
</table>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerStore</span> <code class='quiet'>(Peerstore)</code>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='destroy'>
destroy
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/dialer/index.js#L49-L58'>
<span>src/dialer/index.js</span>
</a>
</div>
<p>Clears any pending dials</p>
<div class='pre p1 fill-light mt0'>destroy()</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='connecttopeer'>
connectToPeer
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/dialer/index.js#L70-L91'>
<span>src/dialer/index.js</span>
</a>
</div>
<p>Connects to a given <code>PeerId</code> or <code>Multiaddr</code> by dialing all of its known addresses.
The dial to the first address that is successfully able to upgrade a connection
will be used.</p>
<div class='pre p1 fill-light mt0'>connectToPeer(peer: (PeerInfo | Multiaddr), options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peer</span> <code class='quiet'>((PeerInfo | Multiaddr))</code>
The peer to dial
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?
= <code>{}</code>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.signal</span> <code class='quiet'>AbortSignal?</code>
</td>
<td class='break-word'><span>An AbortController signal
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='_createdialtarget'>
_createDialTarget
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/dialer/index.js#L106-L119'>
<span>src/dialer/index.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>_createDialTarget(peer: any)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peer</span> <code class='quiet'>(any)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Properties</div>
<div>
<div class='space-bottom0'>
<span class='code bold'>id</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
</div>
<div class='space-bottom0'>
<span class='code bold'>addrs</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr>)</code>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='_creatependingdial'>
_createPendingDial
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/dialer/index.js#L137-L166'>
<span>src/dialer/index.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>_createPendingDial(dialTarget: any, options: any)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>dialTarget</span> <code class='quiet'>(any)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(any)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Properties</div>
<div>
<div class='space-bottom0'>
<span class='code bold'>dialRequest</span> <code class='quiet'>(DialRequest)</code>
</div>
<div class='space-bottom0'>
<span class='code bold'>controller</span> <code class='quiet'>(TimeoutController)</code>
</div>
<div class='space-bottom0'>
<span class='code bold'>promise</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>)</code>
</div>
<div class='space-bottom0'>
<span class='code bold'>destroy</span> <code class='quiet'>(function (): void)</code>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='getdialable'>
getDialable
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/dialer/index.js#L188-L210'>
<span>src/dialer/index.js</span>
</a>
</div>
<p>Converts the given <code>peer</code> into a <code>PeerInfo</code> or <code>Multiaddr</code>.</p>
<div class='pre p1 fill-light mt0'>getDialable(peer: (PeerInfo | PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)): (PeerInfo | Multiaddr)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peer</span> <code class='quiet'>((PeerInfo | PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>(PeerInfo | Multiaddr)</code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='constructor'>
constructor
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/dialer/dial-request.js#L24-L32'>
<span>src/dialer/dial-request.js</span>
</a>
</div>
<p>Manages running the <code>dialAction</code> on multiple provided <code>addrs</code> in parallel
up to a maximum determined by the number of tokens returned
from <code>dialer.getTokens</code>. Once a DialRequest is created, it can be
started using <code>DialRequest.run(options)</code>. Once a single dial has succeeded,
all other dials in the request will be cancelled.</p>
<div class='pre p1 fill-light mt0'>constructor(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.addrs</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr></code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.dialAction</span> <code class='quiet'>function (Multiaddr): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.dialer</span> <code class='quiet'>Dialer</code>
</td>
<td class='break-word'><span></span></td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='run'>
run
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/dialer/dial-request.js#L40-L77'>
<span>src/dialer/dial-request.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>run(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>): Connection</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.signal</span> <code class='quiet'>AbortSignal</code>
</td>
<td class='break-word'><span>An AbortController signal
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>Connection</code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='constructor'>
constructor
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/index.js#L29-L37'>
<span>src/metrics/index.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>constructor(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.computeThrottleMaxQueueSize</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.computeThrottleTimeout</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.movingAverageIntervals</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>></code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.maxOldPeersRetention</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='start'>
start
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/index.js#L43-L45'>
<span>src/metrics/index.js</span>
</a>
</div>
<p>Must be called for stats to saved. Any data pushed for tracking
will be ignored.</p>
<div class='pre p1 fill-light mt0'>start()</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='stop'>
stop
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/index.js#L51-L60'>
<span>src/metrics/index.js</span>
</a>
</div>
<p>Stops all averages timers and prevents new data from being tracked.
Once <code>stop</code> is called, <code>start</code> must be called to resume stats tracking.</p>
<div class='pre p1 fill-light mt0'>stop()</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='global'>
global
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/index.js#L66-L68'>
<span>src/metrics/index.js</span>
</a>
</div>
<p>Gets the global <code>Stats</code> object</p>
<div class='pre p1 fill-light mt0'>global</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="#stats">Stats</a></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='peers'>
peers
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/index.js#L74-L76'>
<span>src/metrics/index.js</span>
</a>
</div>
<p>Returns a list of <code>PeerId</code> strings currently being tracked</p>
<div class='pre p1 fill-light mt0'>peers</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='forpeer'>
forPeer
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/index.js#L84-L87'>
<span>src/metrics/index.js</span>
</a>
</div>
<p>Returns the <code>Stats</code> object for the given <code>PeerId</code> whether it
is a live peer, or in the disconnected peer LRU cache.</p>
<div class='pre p1 fill-light mt0'>forPeer(peerId: PeerId): <a href="#stats">Stats</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="#stats">Stats</a></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='protocols'>
protocols
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/index.js#L93-L95'>
<span>src/metrics/index.js</span>
</a>
</div>
<p>Returns a list of all protocol strings currently being tracked.</p>
<div class='pre p1 fill-light mt0'>protocols</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='forprotocol'>
forProtocol
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/index.js#L102-L104'>
<span>src/metrics/index.js</span>
</a>
</div>
<p>Returns the <code>Stats</code> object for the given <code>protocol</code>.</p>
<div class='pre p1 fill-light mt0'>forProtocol(protocol: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="#stats">Stats</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>protocol</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="#stats">Stats</a></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='onpeerdisconnected'>
onPeerDisconnected
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/index.js#L112-L120'>
<span>src/metrics/index.js</span>
</a>
</div>
<p>Should be called when all connections to a given peer
have closed. The <code>Stats</code> collection for the peer will
be stopped and moved to an LRU for temporary retention.</p>
<div class='pre p1 fill-light mt0'>onPeerDisconnected(peerId: PeerId)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='updateplaceholder'>
updatePlaceholder
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/index.js#L168-L186'>
<span>src/metrics/index.js</span>
</a>
</div>
<p>Replaces the <code>PeerId</code> string with the given <code>peerId</code>.
If stats are already being tracked for the given <code>peerId</code>, the
placeholder stats will be merged with the existing stats.</p>
<div class='pre p1 fill-light mt0'>updatePlaceholder(placeholder: PeerId, peerId: PeerId)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>placeholder</span> <code class='quiet'>(PeerId)</code>
A peerId string
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='trackstream'>
trackStream
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/index.js#L201-L226'>
<span>src/metrics/index.js</span>
</a>
</div>
<p>Tracks data running through a given Duplex Iterable <code>stream</code>. If
the <code>peerId</code> is not provided, a placeholder string will be created and
returned. This allows lazy tracking of a peer when the peer is not yet known.
When the <code>PeerId</code> is known, <code>Metrics.updatePlaceholder</code> should be called
with the placeholder string returned from here, and the known <code>PeerId</code>.</p>
<div class='pre p1 fill-light mt0'>trackStream(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.stream</span> <code class='quiet'>{sink: function (any), source: function ()}</code>
</td>
<td class='break-word'><span>A duplex iterable stream
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.protocol</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>?</code>
</td>
<td class='break-word'><span>The protocol the stream is running
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.peerId</span> <code class='quiet'>PeerId?</code>
</td>
<td class='break-word'><span>The id of the remote peer that's connected
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.remotePeer</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code>:
The peerId string or placeholder string
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='mergestats'>
mergeStats
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/index.js#L235-L244'>
<span>src/metrics/index.js</span>
</a>
</div>
<p>Merges <code>other</code> into <code>target</code>. <code>target</code> will be modified
and returned.</p>
<div class='pre p1 fill-light mt0'>mergeStats(target: <a href="#stats">Stats</a>, other: <a href="#stats">Stats</a>): <a href="#stats">Stats</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>target</span> <code class='quiet'>(<a href="#stats">Stats</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>other</span> <code class='quiet'>(<a href="#stats">Stats</a>)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="#stats">Stats</a></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='old-peers'>
old-peers
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/old-peers.js#L11-L15'>
<span>src/metrics/old-peers.js</span>
</a>
</div>
<p>Creates and returns a Least Recently Used Cache</p>
<div class='pre p1 fill-light mt0'>old-peers(maxSize: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>): LRUCache</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>maxSize</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>LRUCache</code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='stats'>
Stats
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/stats.js#L14-L262'>
<span>src/metrics/stats.js</span>
</a>
</div>
<p>A queue based manager for stat processing</p>
<div class='pre p1 fill-light mt0'>new Stats(initialCounters: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>>, options: any)</div>
<p>
Extends
EventEmitter
</p>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>initialCounters</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(any)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
<div class="clearfix">
<div class='border-bottom' id='statsstart'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>start()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/stats.js#L49-L53'>
<span>src/metrics/stats.js</span>
</a>
</div>
<p>Initializes the internal timer if there are items in the queue. This
should only need to be called if <code>Stats.stop</code> was previously called, as
<code>Stats.push</code> will also start the processing.</p>
<div class='pre p1 fill-light mt0'>start(): void</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
</div>
</div>
<div class='border-bottom' id='statsstop'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>stop()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/stats.js#L61-L66'>
<span>src/metrics/stats.js</span>
</a>
</div>
<p>Stops processing and computing of stats by clearing the internal
timer.</p>
<div class='pre p1 fill-light mt0'>stop(): void</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
</div>
</div>
<div class='border-bottom' id='statssnapshot'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>snapshot</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/stats.js#L73-L75'>
<span>src/metrics/stats.js</span>
</a>
</div>
<p>Returns a clone of the current stats.</p>
<div class='pre p1 fill-light mt0'>snapshot</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map">Map</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, Stat></code>:
</section>
</div>
</div>
<div class='border-bottom' id='statsmovingaverages'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>movingAverages</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/stats.js#L82-L84'>
<span>src/metrics/stats.js</span>
</a>
</div>
<p>Returns a clone of the internal movingAverages</p>
<div class='pre p1 fill-light mt0'>movingAverages</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;MovingAverage></code>:
</section>
</div>
</div>
<div class='border-bottom' id='statstojson'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>toJSON()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/stats.js#L91-L109'>
<span>src/metrics/stats.js</span>
</a>
</div>
<p>Returns a plain JSON object of the stats</p>
<div class='pre p1 fill-light mt0'>toJSON(): any</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>any</code>:
</section>
</div>
</div>
<div class='border-bottom' id='statspush'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>push(counter, inc)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/metrics/stats.js#L119-L122'>
<span>src/metrics/stats.js</span>
</a>
</div>
<p>Pushes the given operation data to the queue, along with the
current Timestamp, then resets the update timer.</p>
<div class='pre p1 fill-light mt0'>push(counter: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, inc: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>): void</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>counter</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>inc</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='constructor'>
constructor
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/transport-manager.js#L17-L22'>
<span>src/transport-manager.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>new constructor(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.libp2p</span> <code class='quiet'><a href="#libp2p">Libp2p</a></code>
</td>
<td class='break-word'><span>The Libp2p instance. It will be passed to the transports.
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.upgrader</span> <code class='quiet'><a href="#upgrader">Upgrader</a></code>
</td>
<td class='break-word'><span>The upgrader to provide to the transports
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='add'>
add
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/transport-manager.js#L32-L51'>
<span>src/transport-manager.js</span>
</a>
</div>
<p>Adds a <code>Transport</code> to the manager</p>
<div class='pre p1 fill-light mt0'>add(key: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, Transport: Transport, transportOptions: any): void</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>key</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>Transport</span> <code class='quiet'>(Transport)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>transportOptions</span> <code class='quiet'>(any
= <code>{}</code>)</code>
Additional options to pass to the transport
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='close'>
close
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/transport-manager.js#L57-L72'>
<span>src/transport-manager.js</span>
</a>
</div>
<p>Stops all listeners</p>
<div class='pre p1 fill-light mt0'>close()</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='dial'>
dial
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/transport-manager.js#L80-L92'>
<span>src/transport-manager.js</span>
</a>
</div>
<p>Dials the given Multiaddr over it's supported transport</p>
<div class='pre p1 fill-light mt0'>dial(ma: Multiaddr, options: any): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>ma</span> <code class='quiet'>(Multiaddr)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(any)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='getaddrs'>
getAddrs
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/transport-manager.js#L98-L106'>
<span>src/transport-manager.js</span>
</a>
</div>
<p>Returns all Multiaddr's the listeners are using</p>
<div class='pre p1 fill-light mt0'>getAddrs(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr></div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='gettransports'>
getTransports
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/transport-manager.js#L112-L114'>
<span>src/transport-manager.js</span>
</a>
</div>
<p>Returns all the transports instances.</p>
<div class='pre p1 fill-light mt0'>getTransports(): Iterator&#x3C;Transport></div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>Iterator&#x3C;Transport></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='transportformultiaddr'>
transportForMultiaddr
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/transport-manager.js#L121-L127'>
<span>src/transport-manager.js</span>
</a>
</div>
<p>Finds a transport that matches the given Multiaddr</p>
<div class='pre p1 fill-light mt0'>transportForMultiaddr(ma: Multiaddr): (Transport | null)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>ma</span> <code class='quiet'>(Multiaddr)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>(Transport | null)</code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='listen'>
listen
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/transport-manager.js#L134-L177'>
<span>src/transport-manager.js</span>
</a>
</div>
<p>Starts listeners for each given Multiaddr.</p>
<div class='pre p1 fill-light mt0'>listen(addrs: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>addrs</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr>)</code>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='remove'>
remove
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/transport-manager.js#L186-L197'>
<span>src/transport-manager.js</span>
</a>
</div>
<p>Removes the given transport from the manager.
If a transport has any running listeners, they will be closed.</p>
<div class='pre p1 fill-light mt0'>remove(key: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>key</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='removeall'>
removeAll
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/transport-manager.js#L204-L211'>
<span>src/transport-manager.js</span>
</a>
</div>
<p>Removes all transports from the manager.
If any listeners are running, they will be closed.</p>
<div class='pre p1 fill-light mt0'>removeAll()</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='upgrader'>
Upgrader
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/upgrader.js#L30-L418'>
<span>src/upgrader.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>new Upgrader($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>$0.localPeer</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.metrics</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.cryptos</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.muxers</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.onConnectionEnd</span> <code class='quiet'>any</code>
(default <code>()=&gt;{}</code>)
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.onConnection</span> <code class='quiet'>any</code>
(default <code>()=&gt;{}</code>)
</td>
<td class='break-word'><span></span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Properties</div>
<div>
<div class='space-bottom0'>
<span class='code bold'>sink</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">function</a>)</code>
</div>
<div class='space-bottom0'>
<span class='code bold'>source</span> <code class='quiet'>(AsyncIterator)</code>
</div>
<div class='space-bottom0'>
<span class='code bold'>conn</span> <code class='quiet'>(any)</code>
</div>
<div class='space-bottom0'>
<span class='code bold'>remoteAddr</span> <code class='quiet'>(Multiaddr)</code>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
<div class="clearfix">
<div class='border-bottom' id='upgraderupgradeinbound'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>upgradeInbound(maConn)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/upgrader.js#L64-L123'>
<span>src/upgrader.js</span>
</a>
</div>
<p>Upgrades an inbound connection</p>
<div class='pre p1 fill-light mt0'>upgradeInbound(maConn: MultiaddrConnection): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>maConn</span> <code class='quiet'>(MultiaddrConnection)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></code>:
</section>
</div>
</div>
<div class='border-bottom' id='upgraderupgradeoutbound'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>upgradeOutbound(maConn)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/upgrader.js#L131-L197'>
<span>src/upgrader.js</span>
</a>
</div>
<p>Upgrades an outbound connection</p>
<div class='pre p1 fill-light mt0'>upgradeOutbound(maConn: MultiaddrConnection): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>maConn</span> <code class='quiet'>(MultiaddrConnection)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></code>:
</section>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='upgrader'>
Upgrader
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/upgrader.js#L30-L418'>
<span>src/upgrader.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>new Upgrader($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>$0.localPeer</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.metrics</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.cryptos</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.muxers</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.onConnectionEnd</span> <code class='quiet'>any</code>
(default <code>()=&gt;{}</code>)
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>$0.onConnection</span> <code class='quiet'>any</code>
(default <code>()=&gt;{}</code>)
</td>
<td class='break-word'><span></span></td>
</tr>
</tbody>
</table>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Properties</div>
<div>
<div class='space-bottom0'>
<span class='code bold'>conn</span> <code class='quiet'>(any)</code>
: A duplex iterable
</div>
<div class='space-bottom0'>
<span class='code bold'>remotePeer</span> <code class='quiet'>(PeerId)</code>
</div>
<div class='space-bottom0'>
<span class='code bold'>protocol</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
<div class="clearfix">
<div class='border-bottom' id='upgraderupgradeinbound'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>upgradeInbound(maConn)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/upgrader.js#L64-L123'>
<span>src/upgrader.js</span>
</a>
</div>
<p>Upgrades an inbound connection</p>
<div class='pre p1 fill-light mt0'>upgradeInbound(maConn: MultiaddrConnection): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>maConn</span> <code class='quiet'>(MultiaddrConnection)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></code>:
</section>
</div>
</div>
<div class='border-bottom' id='upgraderupgradeoutbound'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>upgradeOutbound(maConn)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/upgrader.js#L131-L197'>
<span>src/upgrader.js</span>
</a>
</div>
<p>Upgrades an outbound connection</p>
<div class='pre p1 fill-light mt0'>upgradeOutbound(maConn: MultiaddrConnection): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>maConn</span> <code class='quiet'>(MultiaddrConnection)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;Connection></code>:
</section>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='peerstore'>
PeerStore
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/peer-store/index.js#L22-L251'>
<span>src/peer-store/index.js</span>
</a>
</div>
<p>Responsible for managing known peers, as well as their addresses and metadata</p>
<div class='pre p1 fill-light mt0'>new PeerStore()</div>
<p>
Extends
EventEmitter
</p>
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
<div class="clearfix">
<div class='border-bottom' id='peerstorepeers'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>peers</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/peer-store/index.js#L31-L31'>
<span>src/peer-store/index.js</span>
</a>
</div>
<p>Map of peers</p>
<div class='pre p1 fill-light mt0'>peers</div>
<p>
Type:
<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map">Map</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, PeerInfo>
</p>
</section>
</div>
</div>
<div class='border-bottom' id='peerstoreput'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>put(peerInfo, options = {silent:false})</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/peer-store/index.js#L51-L67'>
<span>src/peer-store/index.js</span>
</a>
</div>
<p>Stores the peerInfo of a new peer.
If already exist, its info is updated. If <code>silent</code> is set to
true, no 'peer' event will be emitted. This can be useful if you
are already in the process of dialing the peer. The peer is technically
known, but may not have been added to the PeerStore yet.</p>
<div class='pre p1 fill-light mt0'>put(peerInfo: PeerInfo, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?): PeerInfo</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerInfo</span> <code class='quiet'>(PeerInfo)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?
= <code>{silent:false}</code>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.silent</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>?</code>
</td>
<td class='break-word'><span>(Default=false)
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>PeerInfo</code>:
</section>
</div>
</div>
<div class='border-bottom' id='peerstoreadd'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>add(peerInfo)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/peer-store/index.js#L74-L107'>
<span>src/peer-store/index.js</span>
</a>
</div>
<p>Add a new peer to the store.</p>
<div class='pre p1 fill-light mt0'>add(peerInfo: PeerInfo): PeerInfo</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerInfo</span> <code class='quiet'>(PeerInfo)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>PeerInfo</code>:
</section>
</div>
</div>
<div class='border-bottom' id='peerstoreupdate'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>update(peerInfo)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/peer-store/index.js#L114-L170'>
<span>src/peer-store/index.js</span>
</a>
</div>
<p>Updates an already known peer.</p>
<div class='pre p1 fill-light mt0'>update(peerInfo: PeerInfo): PeerInfo</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerInfo</span> <code class='quiet'>(PeerInfo)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>PeerInfo</code>:
</section>
</div>
</div>
<div class='border-bottom' id='peerstoreget'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>get(peerId)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/peer-store/index.js#L177-L184'>
<span>src/peer-store/index.js</span>
</a>
</div>
<p>Get the info to the given id.</p>
<div class='pre p1 fill-light mt0'>get(peerId: (PeerId | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)): PeerInfo</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerId</span> <code class='quiet'>((PeerId | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
b58str id
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>PeerInfo</code>:
</section>
</div>
</div>
<div class='border-bottom' id='peerstorehas'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>has(peerId)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/peer-store/index.js#L191-L198'>
<span>src/peer-store/index.js</span>
</a>
</div>
<p>Has the info to the given id.</p>
<div class='pre p1 fill-light mt0'>has(peerId: (PeerId | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerId</span> <code class='quiet'>((PeerId | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
b58str id
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code>:
</section>
</div>
</div>
<div class='border-bottom' id='peerstoreremove'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>remove(peerId)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/peer-store/index.js#L205-L212'>
<span>src/peer-store/index.js</span>
</a>
</div>
<p>Removes the Peer with the matching <code>peerId</code> from the PeerStore</p>
<div class='pre p1 fill-light mt0'>remove(peerId: (PeerId | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerId</span> <code class='quiet'>((PeerId | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
b58str id
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code>:
true if found and removed
</section>
</div>
</div>
<div class='border-bottom' id='peerstorereplace'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>replace(peerInfo)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/peer-store/index.js#L219-L236'>
<span>src/peer-store/index.js</span>
</a>
</div>
<p>Completely replaces the existing peers metadata with the given <code>peerInfo</code></p>
<div class='pre p1 fill-light mt0'>replace(peerInfo: PeerInfo): void</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerInfo</span> <code class='quiet'>(PeerInfo)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
</div>
</div>
<div class='border-bottom' id='peerstoremultiaddrsforpeer'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>multiaddrsForPeer(peer)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/peer-store/index.js#L244-L250'>
<span>src/peer-store/index.js</span>
</a>
</div>
<p>Returns the known multiaddrs for a given <code>PeerInfo</code>. All returned multiaddrs
will include the encapsulated <code>PeerId</code> of the peer.</p>
<div class='pre p1 fill-light mt0'>multiaddrsForPeer(peer: PeerInfo): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peer</span> <code class='quiet'>(PeerInfo)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr></code>:
</section>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='registrar'>
Registrar
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/registrar.js#L18-L170'>
<span>src/registrar.js</span>
</a>
</div>
<p>Responsible for notifying registered protocols of events in the network.</p>
<div class='pre p1 fill-light mt0'>new Registrar($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, props: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>$0.peerStore</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
</tbody>
</table>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>props</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
<div class="clearfix">
<div class='border-bottom' id='registrarconnections'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>connections</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/registrar.js#L32-L32'>
<span>src/registrar.js</span>
</a>
</div>
<p>Map of connections per peer
TODO: this should be handled by connectionManager</p>
<div class='pre p1 fill-light mt0'>connections</div>
<p>
Type:
<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map">Map</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;conn>>
</p>
</section>
</div>
</div>
<div class='border-bottom' id='registrartopologies'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>topologies</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/registrar.js#L39-L39'>
<span>src/registrar.js</span>
</a>
</div>
<p>Map of topologies</p>
<div class='pre p1 fill-light mt0'>topologies</div>
<p>
Type:
<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map">Map</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>>
</p>
</section>
</div>
</div>
<div class='border-bottom' id='registrarclose'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>close()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/registrar.js#L56-L67'>
<span>src/registrar.js</span>
</a>
</div>
<p>Cleans up the registrar</p>
<div class='pre p1 fill-light mt0'>close()</div>
</section>
</div>
</div>
<div class='border-bottom' id='registraronconnect'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>onConnect(peerInfo, conn)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/registrar.js#L76-L93'>
<span>src/registrar.js</span>
</a>
</div>
<p>Add a new connected peer to the record
TODO: this should live in the ConnectionManager</p>
<div class='pre p1 fill-light mt0'>onConnect(peerInfo: PeerInfo, conn: Connection): void</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerInfo</span> <code class='quiet'>(PeerInfo)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>conn</span> <code class='quiet'>(Connection)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
</div>
</div>
<div class='border-bottom' id='registrarondisconnect'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>onDisconnect(peerInfo, connection, error?)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/registrar.js#L103-L121'>
<span>src/registrar.js</span>
</a>
</div>
<p>Remove a disconnected peer from the record
TODO: this should live in the ConnectionManager</p>
<div class='pre p1 fill-light mt0'>onDisconnect(peerInfo: PeerInfo, connection: Connection, error: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>?): void</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerInfo</span> <code class='quiet'>(PeerInfo)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>connection</span> <code class='quiet'>(Connection)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>error</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>?)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
</div>
</div>
<div class='border-bottom' id='registrargetconnection'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>getConnection(peerInfo)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/registrar.js#L128-L139'>
<span>src/registrar.js</span>
</a>
</div>
<p>Get a connection with a peer.</p>
<div class='pre p1 fill-light mt0'>getConnection(peerInfo: PeerInfo): Connection</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerInfo</span> <code class='quiet'>(PeerInfo)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>Connection</code>:
</section>
</div>
</div>
<div class='border-bottom' id='registrarregister'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>register(topology)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/registrar.js#L146-L160'>
<span>src/registrar.js</span>
</a>
</div>
<p>Register handlers for a set of multicodecs given</p>
<div class='pre p1 fill-light mt0'>register(topology: Topology): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>topology</span> <code class='quiet'>(Topology)</code>
protocol topology
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code>:
registrar identifier
</section>
</div>
</div>
<div class='border-bottom' id='registrarunregister'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>unregister(id)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/registrar.js#L167-L169'>
<span>src/registrar.js</span>
</a>
</div>
<p>Unregister topology.</p>
<div class='pre p1 fill-light mt0'>unregister(id: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>id</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
registrar identifier
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code>:
unregistered successfully
</section>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='ping'>
ping
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/ping/index.js#L21-L43'>
<span>src/ping/index.js</span>
</a>
</div>
<p>Ping a given peer and wait for its response, getting the operation latency.</p>
<div class='pre p1 fill-light mt0'>ping(node: <a href="#libp2p">Libp2p</a>, peer: PeerInfo): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>node</span> <code class='quiet'>(<a href="#libp2p">Libp2p</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>peer</span> <code class='quiet'>(PeerInfo)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='mount'>
mount
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/ping/index.js#L49-L51'>
<span>src/ping/index.js</span>
</a>
</div>
<p>Subscribe ping protocol handler.</p>
<div class='pre p1 fill-light mt0'>mount(node: <a href="#libp2p">Libp2p</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>node</span> <code class='quiet'>(<a href="#libp2p">Libp2p</a>)</code>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='unmount'>
unmount
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/ping/index.js#L57-L59'>
<span>src/ping/index.js</span>
</a>
</div>
<p>Unsubscribe ping protocol handler.</p>
<div class='pre p1 fill-light mt0'>unmount(node: <a href="#libp2p">Libp2p</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>node</span> <code class='quiet'>(<a href="#libp2p">Libp2p</a>)</code>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='constructor'>
constructor
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/identify/index.js#L87-L100'>
<span>src/identify/index.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>new constructor(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.registrar</span> <code class='quiet'><a href="#registrar">Registrar</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.protocols</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map">Map</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, handler></code>
</td>
<td class='break-word'><span>A reference to the protocols we support
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.peerInfo</span> <code class='quiet'>PeerInfo</code>
</td>
<td class='break-word'><span>The peer running the identify service
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='registrar'>
registrar
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/identify/index.js#L91-L91'>
<span>src/identify/index.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>registrar</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='peerinfo'>
peerInfo
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/identify/index.js#L95-L95'>
<span>src/identify/index.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>peerInfo</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='push'>
push
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/identify/index.js#L107-L128'>
<span>src/identify/index.js</span>
</a>
</div>
<p>Send an Identify Push update to the list of connections</p>
<div class='pre p1 fill-light mt0'>push(connections: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Connection>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>connections</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Connection>)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='pushtopeerstore'>
pushToPeerStore
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/identify/index.js#L134-L144'>
<span>src/identify/index.js</span>
</a>
</div>
<p>Calls <code>push</code> for all peers in the <code>peerStore</code> that are connected</p>
<div class='pre p1 fill-light mt0'>pushToPeerStore(peerStore: <a href="#peerstore">PeerStore</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerStore</span> <code class='quiet'>(<a href="#peerstore">PeerStore</a>)</code>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='identify'>
identify
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/identify/index.js#L155-L200'>
<span>src/identify/index.js</span>
</a>
</div>
<p>Requests the <code>Identify</code> message from peer associated with the given <code>connection</code>.
If the identified peer does not match the <code>PeerId</code> associated with the connection,
an error will be thrown.</p>
<div class='pre p1 fill-light mt0'>identify(connection: Connection): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>connection</span> <code class='quiet'>(Connection)</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='handlemessage'>
handleMessage
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/identify/index.js#L211-L220'>
<span>src/identify/index.js</span>
</a>
</div>
<p>A handler to register with Libp2p to process identify messages.</p>
<div class='pre p1 fill-light mt0'>handleMessage(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.connection</span> <code class='quiet'>Connection</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.stream</span> <code class='quiet'>any</code>
</td>
<td class='break-word'><span></span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.protocol</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;void></code>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='updatepeeraddresses'>
updatePeerAddresses
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/identify/index.js#L37-L48'>
<span>src/identify/index.js</span>
</a>
</div>
<p>Replaces the multiaddrs on the given <code>peerInfo</code>,
with the provided <code>multiaddrs</code></p>
<div class='pre p1 fill-light mt0'>updatePeerAddresses(peerInfo: PeerInfo, multiaddrs: (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://nodejs.org/api/buffer.html">Buffer</a>>))</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerInfo</span> <code class='quiet'>(PeerInfo)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>multiaddrs</span> <code class='quiet'>((<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;Multiaddr> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://nodejs.org/api/buffer.html">Buffer</a>>))</code>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='updatepeerprotocols'>
updatePeerProtocols
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/identify/index.js#L57-L62'>
<span>src/identify/index.js</span>
</a>
</div>
<p>Replaces the protocols on the given <code>peerInfo</code>,
with the provided <code>protocols</code></p>
<div class='pre p1 fill-light mt0'>updatePeerProtocols(peerInfo: PeerInfo, protocols: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>peerInfo</span> <code class='quiet'>(PeerInfo)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>protocols</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>>)</code>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='getcleanmultiaddr'>
getCleanMultiaddr
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/9197df309bd31dfeba845d08bc135ce5b9d03515/src/identify/index.js#L69-L78'>
<span>src/identify/index.js</span>
</a>
</div>
<p>Takes the <code>addr</code> and converts it to a Multiaddr if possible</p>
<div class='pre p1 fill-light mt0'>getCleanMultiaddr(addr: (<a href="https://nodejs.org/api/buffer.html">Buffer</a> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)): (Multiaddr | null)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>addr</span> <code class='quiet'>((<a href="https://nodejs.org/api/buffer.html">Buffer</a> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>))</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>(Multiaddr | null)</code>:
</section>
</div>
</div>
<script src='assets/anchor.js'></script>
<script src='assets/split.js'></script>
<script src='assets/site.js'></script>
</body>
</html>