2018-02-07 08:40:53 +00:00
<!doctype html>
2019-08-21 19:52:04 +02:00
< html >
< head >
< meta charset = 'utf-8' >
2019-09-24 14:11:13 +02:00
< title > libp2p 0.26.2 | Documentation< / title >
2019-08-21 19:52:04 +02:00
< 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 >
2019-09-24 14:11:13 +02:00
< div class = 'mb1' > < code > 0.26.2< / code > < / div >
2019-08-21 19:52:04 +02:00
< input
placeholder='Filter'
id='filter-input'
class='col12 block input'
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 > 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='#libp2pdial'
class='regular pre-open'>
#dial
< / a > < / li >
< li > < a
href='#libp2pdialprotocol'
class='regular pre-open'>
#dialProtocol
< / a > < / li >
< li > < a
href='#libp2pdialfsm'
class='regular pre-open'>
#dialFSM
< / a > < / li >
< li > < a
href='#libp2phangup'
class='regular pre-open'>
#hangUp
< / a > < / li >
< li > < a
href='#libp2pping'
class='regular pre-open'>
#ping
< / a > < / li >
< / ul >
< / div >
< / li >
< li > < a
href='#createlibp2p'
class="">
createLibp2p
< / a >
< / li >
< li > < a
href='#switch'
class=" toggle-sibling">
Switch
< 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='#switchavailabletransports'
class='regular pre-open'>
#availableTransports
< / a > < / li >
< li > < a
href='#switchhandle'
class='regular pre-open'>
#handle
< / a > < / li >
< li > < a
href='#switchunhandle'
class='regular pre-open'>
#unhandle
< / a > < / li >
< li > < a
href='#switchhangup'
class='regular pre-open'>
#hangUp
< / a > < / li >
< li > < a
href='#switchhastransports'
class='regular pre-open'>
#hasTransports
< / a > < / li >
< li > < a
href='#switchstart'
class='regular pre-open'>
#start
< / a > < / li >
< li > < a
href='#switchstop'
class='regular pre-open'>
#stop
< / a > < / li >
< / ul >
< / div >
< / li >
< li > < a
href='#constructor'
class="">
constructor
< / a >
< / li >
< li > < a
href='#_dialswarmrelays'
class="">
_dialSwarmRelays
< / 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='#constructor'
class="">
constructor
< / a >
< / li >
< li > < a
href='#_dialrelayhelper'
class="">
_dialRelayHelper
< / a >
< / li >
< li > < a
href='#dial'
class="">
dial
< / a >
< / li >
< li > < a
href='#canhop'
class="">
canHop
< / 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='#getrawconn'
class="">
getRawConn
< / a >
< / li >
< li > < a
href='#rest'
class="">
rest
< / a >
< / li >
< li > < a
href='#close'
class="">
close
< / a >
< / li >
< li > < a
href='#getb58string'
class="">
getB58String
< / a >
< / li >
< li > < a
href='#ispeerconnected'
class="">
isPeerConnected
< / a >
< / li >
< li > < a
href='#writeresponse'
class="">
writeResponse
< / a >
< / li >
< li > < a
href='#validateaddrs'
class="">
validateAddrs
< / a >
< / li >
< li > < a
href='#listen'
class="">
listen
< / a >
< / li >
< li > < a
href='#close'
class="">
close
< / a >
< / li >
< li > < a
href='#getaddrs'
class="">
getAddrs
< / a >
< / li >
< li > < a
href='#handle'
class="">
handle
< / a >
< / li >
< li > < a
href='#constructor'
class="">
constructor
< / a >
< / li >
< li > < a
href='#handle'
class="">
handle
< / a >
< / li >
< li > < a
href='#_connecttostop'
class="">
_connectToStop
< / a >
< / li >
< li > < a
href='#_negotiatestop'
class="">
_negotiateStop
< / a >
< / li >
< li > < a
href='#transportmanager'
class=" toggle-sibling">
TransportManager
< 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='#transportmanagerdialables'
class='regular pre-open'>
.dialables
< / a > < / li >
< / ul >
< ul class = 'list-reset py1-ul pl1' >
< li class = 'h5' > < span > Instance members< / span > < / li >
< li > < a
href='#transportmanageradd'
class='regular pre-open'>
#add
< / a > < / li >
< li > < a
href='#transportmanagerremove'
class='regular pre-open'>
#remove
< / a > < / li >
< li > < a
href='#transportmanagerremoveall'
class='regular pre-open'>
#removeAll
< / a > < / li >
< li > < a
href='#transportmanagerdial'
class='regular pre-open'>
#dial
< / a > < / li >
< li > < a
href='#transportmanagerlisten'
class='regular pre-open'>
#listen
< / a > < / li >
< li > < a
href='#transportmanagerclose'
class='regular pre-open'>
#close
< / a > < / li >
< / ul >
< / div >
< / li >
< li > < a
href='#ouraddresses'
class="">
ourAddresses
< / a >
< / li >
< li > < a
href='#getdestination'
class="">
getDestination
< / a >
< / li >
< li > < a
href='#limitdialer'
class=" toggle-sibling">
LimitDialer
< 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='#limitdialerdialmany'
class='regular pre-open'>
#dialMany
< / a > < / li >
< li > < a
href='#limitdialerdialsingle'
class='regular pre-open'>
#dialSingle
< / a > < / li >
< / ul >
< / div >
< / li >
< li > < a
href='#dialqueue'
class=" toggle-sibling">
DialQueue
< 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='#dialqueuepush'
class='regular pre-open'>
#push
< / a > < / li >
< / ul >
< / div >
< / li >
< li > < a
href='#mshandle'
class="">
msHandle
< / a >
< / li >
< li > < a
href='#msselect'
class="">
msSelect
< / a >
< / li >
< li > < a
href='#identifydialer'
class="">
identifyDialer
< / a >
< / li >
< li > < a
href='#uniqueby'
class="">
uniqueBy
< / a >
< / li >
< li > < a
href='#connectionmanager'
class=" toggle-sibling">
ConnectionManager
< 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='#connectionmanageraddstreammuxer'
class='regular pre-open'>
#addStreamMuxer
< / a > < / li >
< li > < a
href='#connectionmanagercrypto'
class='regular pre-open'>
#crypto
< / a > < / li >
< li > < a
href='#connectionmanagerenablecircuitrelay'
class='regular pre-open'>
#enableCircuitRelay
< / a > < / li >
< li > < a
href='#connectionmanagerreuse'
class='regular pre-open'>
#reuse
< / a > < / li >
< / ul >
< / div >
< / li >
< li > < a
href='#connectionoptions'
class="">
ConnectionOptions
< / a >
< / li >
< li > < a
href='#connectionfsm'
class=" toggle-sibling">
ConnectionFSM
< 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='#connectionfsmdial'
class='regular pre-open'>
#dial
< / a > < / li >
< li > < a
href='#connectionfsmshake'
class='regular pre-open'>
#shake
< / a > < / li >
< li > < a
href='#connectionfsmupgrade'
class='regular pre-open'>
#upgrade
< / a > < / li >
< li > < a
href='#connectionfsm_ondialed'
class='regular pre-open'>
#_onDialed
< / a > < / li >
< li > < a
href='#connectionfsm_ondisconnecting'
class='regular pre-open'>
#_onDisconnecting
< / a > < / li >
< li > < a
href='#connectionfsm_didupgrade'
class='regular pre-open'>
#_didUpgrade
< / a > < / li >
< li > < a
href='#connectionfsm_onstateerror'
class='regular pre-open'>
#_onStateError
< / a > < / li >
< / ul >
< / div >
< / li >
< li > < a
href='#_dial'
class="">
_dial
< / a >
< / li >
< li > < a
href='#start'
class="">
start
< / a >
< / li >
< li > < a
href='#stop'
class="">
stop
< / a >
< / li >
< li > < a
href='#cleardenylist'
class="">
clearDenylist
< / a >
< / li >
< li > < a
href='#connect'
class="">
connect
< / a >
< / li >
< li > < a
href='#dial'
class="">
dial
< / a >
< / li >
< li > < a
href='#dialfsm'
class="">
dialFSM
< / 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='#add'
class="">
add
< / a >
< / li >
< li > < a
href='#run'
class="">
run
< / a >
< / li >
< li > < a
href='#cleardenylist'
class="">
clearDenylist
< / a >
< / li >
< li > < a
href='#getqueue'
class="">
getQueue
< / a >
< / li >
< li > < a
href='#dialrequest'
class="">
DialRequest
< / a >
< / li >
< li > < a
href='#newconnection'
class="">
NewConnection
< / a >
< / li >
< li > < a
href='#createconnectionwithprotocol'
class="">
createConnectionWithProtocol
< / a >
< / li >
< li > < a
href='#queue'
class=" toggle-sibling">
Queue
< 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='#queueadd'
class='regular pre-open'>
#add
< / a > < / li >
< li > < a
href='#queueisdialallowed'
class='regular pre-open'>
#isDialAllowed
< / a > < / li >
< li > < a
href='#queuestart'
class='regular pre-open'>
#start
< / a > < / li >
< li > < a
href='#queuestop'
class='regular pre-open'>
#stop
< / a > < / li >
< li > < a
href='#queueabort'
class='regular pre-open'>
#abort
< / a > < / li >
< li > < a
href='#queuedenylist'
class='regular pre-open'>
#denylist
< / a > < / li >
< / ul >
< / div >
< / li >
< li > < a
href='#transportkey'
class="">
transportKey
< / a >
< / li >
< li > < a
href='#conn'
class="">
conn
< / a >
< / li >
< li > < a
href='#close'
class="">
close
< / a >
< / li >
< li > < a
href='#getstate'
class="">
getState
< / a >
< / li >
< li > < a
href='#encrypt'
class="">
encrypt
< / a >
< / li >
< li > < a
href='#protect'
class="">
protect
< / a >
< / li >
< li > < a
href='#upgrade'
class="">
upgrade
< / a >
< / li >
< li > < a
href='#_ondisconnected'
class="">
_onDisconnected
< / a >
< / li >
< li > < a
href='#_onprivatized'
class="">
_onPrivatized
< / a >
< / li >
< li > < a
href='#observe-connection'
class="">
observe-connection
< / a >
< / li >
< li > < a
href='#plaintext'
class="">
plaintext
< / a >
< / li >
< li > < a
href='#observer'
class="">
observer
< / a >
< / li >
< li > < a
href='#'
class="">
< / 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='#statspush'
class='regular pre-open'>
#push
< / a > < / li >
< / ul >
< / div >
< / li >
< li > < a
href='#old-peers'
class="">
old-peers
< / a >
< / 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='#subscribe'
class="">
subscribe
< / a >
< / li >
< li > < a
href='#unsubscribe'
class="">
unsubscribe
< / a >
< / li >
< li > < a
href='#getpeerinfo'
class="">
getPeerInfo
< / a >
< / li >
< li > < a
href='#getpeerinforemote'
class="">
getPeerInfoRemote
< / 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 >
2018-02-07 08:40:53 +00:00
< 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 > Libp2p should work in any ES2015 environment out of the box.< / p >
< p > Usage:< / p >
2019-06-07 17:10:19 +02:00
< pre class = 'hljs' > < span class = "hljs-tag" > < < 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 > > < / span > < span class = "hljs-tag" > < /< span class = "hljs-name" > script< / span > > < / span > < / pre >
2018-11-16 14:12:15 +01:00
< p > The portable versions of libp2p, including < code > index.js< / code > and < code > index.min.js< / code > , are included in the < code > /dist< / code > folder. Libp2p can also be found on < a href = "https://unpkg.com" > unpkg.com< / a > under< / p >
2018-02-07 08:40:53 +00:00
< 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 >
2019-08-21 19:52:04 +02:00
< / section > < / div >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'libp2p' >
Libp2p
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/index.js#L47-L564' >
2019-08-21 19:52:04 +02:00
< 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' > 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' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/index.js#L202-L208' >
2019-08-21 19:52:04 +02:00
< span > src/index.js< / span >
< / a >
< / div >
< p > Overrides EventEmitter.emit to conditionally emit errors
2018-11-16 14:12:15 +01:00
if there is a handler. If not, errors will be logged.< / p >
2019-08-21 19:52:04 +02:00
< 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(callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/index.js#L216-L219' >
2019-08-21 19:52:04 +02:00
< span > src/index.js< / span >
< / a >
< / div >
< p > Starts the libp2p node and all sub services< / p >
< div class = 'pre p1 fill-light mt0' > start(callback: function (< 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' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > )
= < code > ()=> {}< / code > )< / code >
< / div >
< / div >
< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > 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(callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/index.js#L227-L230' >
2019-08-21 19:52:04 +02:00
< 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(callback: function (< 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' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > )
= < code > ()=> {}< / code > )< / code >
< / div >
< / div >
< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > void< / 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, callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/index.js#L244-L246' >
2019-08-21 19:52:04 +02:00
< span > src/index.js< / span >
< / a >
< / div >
< p > Dials to the provided peer. If successful, the < code > PeerInfo< / code > of the
2018-11-16 14:12:15 +01:00
peer will be added to the nodes < code > PeerBook< / code > < / p >
2019-08-21 19:52:04 +02:00
< 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 > ), callback: function (< 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' > 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' > callback< / span > < code class = 'quiet' > (function (< 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 = '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, protocol, callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/index.js#L258-L272' >
2019-08-21 19:52:04 +02:00
< span > src/index.js< / span >
< / a >
< / div >
< p > Dials to the provided peer and handshakes with the given protocol.
2018-11-16 14:12:15 +01:00
If successful, the < code > PeerInfo< / code > of the peer will be added to the nodes < code > PeerBook< / code > ,
and the < code > Connection< / code > will be sent in the callback< / p >
2019-08-21 19:52:04 +02:00
< 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 > ), protocol: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > , callback: function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Connection)): 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 dial
< / div >
< / div >
< 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 class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , 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 = 'libp2pdialfsm' >
< 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' > dialFSM(peer, protocol, callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/index.js#L283-L297' >
2019-08-21 19:52:04 +02:00
< span > src/index.js< / span >
< / a >
< / div >
< p > Similar to < code > dial< / code > and < code > dialProtocol< / code > , but the callback will contain a
2018-11-16 14:12:15 +01:00
Connection State Machine.< / p >
2019-08-21 19:52:04 +02:00
< div class = 'pre p1 fill-light mt0' > dialFSM(peer: (PeerInfo | PeerId | Multiaddr | < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > ), protocol: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > , callback: function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , < a href = "#connectionfsm" > ConnectionFSM< / a > )): 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 dial
< / div >
< / div >
< 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 class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , < a href = "#connectionfsm" > ConnectionFSM< / 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 = '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, callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/index.js#L306-L311' >
2019-08-21 19:52:04 +02:00
< span > src/index.js< / span >
< / a >
< / div >
< p > Disconnects from the given peer< / 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 > ), callback: function (< 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' > 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 class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< 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 = '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, callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/index.js#L320-L329' >
2019-08-21 19:52:04 +02:00
< span > src/index.js< / span >
< / a >
< / div >
< p > Pings the provided 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 > ), callback: function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Ping)): 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 ping
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Ping))< / 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 = 'createlibp2p' >
createLibp2p
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/index.js#L574-L583' >
2019-08-21 19:52:04 +02:00
< span > src/index.js< / span >
< / a >
< / div >
< p > Like < code > new Libp2p(options)< / code > except it will create a < code > PeerInfo< / code >
2019-06-07 17:10:19 +02:00
instance if one is not provided in options.< / p >
2019-08-21 19:52:04 +02:00
< div class = 'pre p1 fill-light mt0' > createLibp2p< / 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 >
Libp2p configuration options
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , < a href = "#libp2p" > Libp2p< / a > ))< / code >
< / 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 = 'switch' >
Switch
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/index.js#L29-L271' >
2019-08-21 19:52:04 +02:00
< span > src/switch/index.js< / span >
< / a >
< / div >
< div class = 'pre p1 fill-light mt0' > new Switch(peerInfo: any, peerBook: any, 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' > peerInfo< / span > < code class = 'quiet' > (any)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > peerBook< / 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' > Instance Members< / div >
< div class = "clearfix" >
< div class = 'border-bottom' id = 'switchavailabletransports' >
< 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' > availableTransports(peerInfo)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/index.js#L124-L136' >
2019-08-21 19:52:04 +02:00
< span > src/switch/index.js< / span >
< / a >
< / div >
< p > Returns a list of the transports peerInfo has addresses for< / p >
< div class = 'pre p1 fill-light mt0' > availableTransports(peerInfo: PeerInfo): < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > < Transport>< / 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 > < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > < Transport>< / code > :
< / section >
< / div >
< / div >
< div class = 'border-bottom' id = 'switchhandle' >
< 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(protocol, handlerFunc, matchFunc)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/index.js#L148-L154' >
2019-08-21 19:52:04 +02:00
< span > src/switch/index.js< / span >
< / a >
< / div >
< p > Adds the < code > handlerFunc< / code > and < code > matchFunc< / code > to the Switch's protocol
handler list for the given < code > protocol< / code > . If the < code > matchFunc< / code > returns
true for a protocol check, the < code > handlerFunc< / code > will be called.< / p >
< div class = 'pre p1 fill-light mt0' > handle(protocol: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > , handlerFunc: function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > , Connection), matchFunc: function (< 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 > , function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean" > boolean< / a > ))): void< / 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 class = 'space-bottom0' >
< div >
< span class = 'code bold' > handlerFunc< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > , Connection))< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > matchFunc< / span > < code class = 'quiet' > (function (< 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 > , function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean" > boolean< / 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 = 'switchunhandle' >
< 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(protocol)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/index.js#L162-L167' >
2019-08-21 19:52:04 +02:00
< span > src/switch/index.js< / span >
< / a >
< / div >
< p > Removes the given protocol from the Switch's protocol list< / p >
< div class = 'pre p1 fill-light mt0' > unhandle(protocol: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > ): void< / 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 > void< / code > :
< / section >
< / div >
< / div >
< div class = 'border-bottom' id = 'switchhangup' >
< 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, callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/index.js#L177-L185' >
2019-08-21 19:52:04 +02:00
< span > src/switch/index.js< / span >
< / a >
< / div >
< p > If a muxed Connection exists for the given peer, it will be closed
and its reference on the Switch will be removed.< / p >
< div class = 'pre p1 fill-light mt0' > hangUp(peer: (PeerInfo | Multiaddr | PeerId), callback: function ()): 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 | Multiaddr | PeerId))< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function ())< / code >
< / div >
< / div >
< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > void< / code > :
< / section >
< / div >
< / div >
< div class = 'border-bottom' id = 'switchhastransports' >
< 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' > hasTransports()< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/index.js#L192-L195' >
2019-08-21 19:52:04 +02:00
< span > src/switch/index.js< / span >
< / a >
< / div >
< p > Returns whether or not the switch has any transports< / p >
< div class = 'pre p1 fill-light mt0' > hasTransports(): < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean" > boolean< / a > < / 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 = 'switchstart' >
< 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(callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/index.js#L203-L208' >
2019-08-21 19:52:04 +02:00
< span > src/switch/index.js< / span >
< / a >
< / div >
< p > Issues a start on the Switch state.< / p >
< div class = 'pre p1 fill-light mt0' > start(callback: < 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' > callback< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > function< / a >
= < code > ()=> {}< / code > )< / code >
deprecated: Listening for the
< code > error< / code >
and
< code > start< / code >
events are recommended
< / div >
< / div >
< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > void< / code > :
< / section >
< / div >
< / div >
< div class = 'border-bottom' id = 'switchstop' >
< 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(callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/index.js#L216-L221' >
2019-08-21 19:52:04 +02:00
< span > src/switch/index.js< / span >
< / a >
< / div >
< p > Issues a stop on the Switch state.< / p >
< div class = 'pre p1 fill-light mt0' > stop(callback: < 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' > callback< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > function< / a >
= < code > ()=> {}< / code > )< / code >
deprecated: Listening for the
< code > error< / code >
and
< code > stop< / code >
events are recommended
< / 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 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit.js#L28-L52' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit.js< / span >
< / a >
< / div >
< p > Creates an instance of Dialer.< / p >
< div class = 'pre p1 fill-light mt0' > constructor(swarm: Swarm, options: any)< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > swarm< / span > < code class = 'quiet' > (Swarm)< / code >
the swarm
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > options< / span > < code class = 'quiet' > (any)< / code >
config options
< / div >
< / div >
< / div >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = '_dialswarmrelays' >
_dialSwarmRelays
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit.js#L60-L73' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit.js< / span >
< / a >
< / div >
< p > Dial the relays in the Addresses.Swarm config< / p >
< div class = 'pre p1 fill-light mt0' > _dialSwarmRelays(relays: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > ): void< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > relays< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > )< / code >
< / 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 = 'dial' >
dial
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit.js#L85-L87' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit.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 > , cb: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > Function< / 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 >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > cb< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > Function< / a > )< / code >
a callback called once dialed
< / div >
< / 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 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit.js#L96-L105' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit.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 > ): listener< / 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 > listener< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'filter' >
filter
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit.js#L116-L123' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit.js< / span >
< / a >
< / div >
< p > Filter check for all multiaddresses
that this transport can dial on< / p >
< div class = 'pre p1 fill-light mt0' > filter(multiaddrs: any): < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > < 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' > (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/Array" > Array< / a > < multiaddr>< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'constructor' >
constructor
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/dialer.js#L29-L35' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit/dialer.js< / span >
< / a >
< / div >
< p > Creates an instance of Dialer.< / p >
< div class = 'pre p1 fill-light mt0' > constructor(swarm: Swarm, options: any)< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > swarm< / span > < code class = 'quiet' > (Swarm)< / code >
the swarm
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > options< / span > < code class = 'quiet' > (any)< / code >
config options
< / div >
< / div >
< / div >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = '_dialrelayhelper' >
_dialRelayHelper
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/dialer.js#L44-L50' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit/dialer.js< / span >
< / a >
< / div >
< p > Helper that returns a relay connection< / p >
< div class = 'pre p1 fill-light mt0' > _dialRelayHelper(relay: any, callback: any): < 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' > relay< / span > < code class = 'quiet' > (any)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / 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/Statements/function" > Function< / a > < / code > :
callback
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'dial' >
dial
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/dialer.js#L60-L88' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit/dialer.js< / span >
< / a >
< / div >
< p > Dial a peer over a relay< / p >
< div class = 'pre p1 fill-light mt0' > dial(ma: multiaddr, cb: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > Function< / 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' > cb< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > Function< / a > )< / code >
a callback called once dialed
< / div >
< / 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 = 'canhop' >
canHop
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/dialer.js#L97-L129' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit/dialer.js< / span >
< / a >
< / div >
< p > Does the peer support the HOP protocol< / p >
< div class = 'pre p1 fill-light mt0' > canHop(peer: PeerInfo, callback: < 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' > peer< / span > < code class = 'quiet' > (PeerInfo)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / 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 > void< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'constructor' >
constructor
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/stream-handler.js#L23-L38' >
2019-08-21 19:52:04 +02:00
< 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(conn: Connection, cb: (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > Function< / a > | < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined" > undefined< / a > ), timeout: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number" > Number< / a > , maxLength: < 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' > conn< / span > < code class = 'quiet' > (Connection)< / code >
connection to read/write
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > cb< / span > < code class = 'quiet' > ((< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > Function< / a > | < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined" > undefined< / a > ))< / code >
handshake callback called on error
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > timeout< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number" > Number< / a > )< / code >
handshake timeout
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > maxLength< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number" > Number< / a > )< / code >
max bytes length of message
< / div >
< / div >
< / div >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'read' >
read
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/stream-handler.js#L50-L67' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit/stream-handler.js< / span >
< / a >
< / div >
< p > Read and decode message< / p >
< div class = 'pre p1 fill-light mt0' > read(cb: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > Function< / a > ): (void | < 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' > cb< / 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 > (void | < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > Function< / a > )< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'write' >
write
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/stream-handler.js#L76-L97' >
2019-08-21 19:52:04 +02:00
< 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: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > < < a href = "https://nodejs.org/api/buffer.html" > Buffer< / a > >, cb: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > Function< / a > ?): < 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' > msg< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > < < a href = "https://nodejs.org/api/buffer.html" > Buffer< / a > >)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > cb< / 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 = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > Function< / a > < / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'getrawconn' >
getRawConn
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/stream-handler.js#L104-L106' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit/stream-handler.js< / span >
< / a >
< / div >
< p > Get the raw Connection< / p >
< div class = 'pre p1 fill-light mt0' > getRawConn(): (null | Connection | any)< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > (null | Connection | any)< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'rest' >
rest
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/stream-handler.js#L113-L120' >
2019-08-21 19:52:04 +02:00
< 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 | {source, sink})< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > (any | {source, sink})< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'close' >
close
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/stream-handler.js#L127-L137' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit/stream-handler.js< / span >
< / a >
< / div >
< p > Close the stream< / p >
< div class = 'pre p1 fill-light mt0' > close(): < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined" > undefined< / a > < / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined" > undefined< / a > < / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'getb58string' >
getB58String
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/utils.js#L16-L26' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit/utils.js< / span >
< / a >
< / div >
< p > Get b58 string from multiaddr or peerinfo< / p >
< div class = 'pre p1 fill-light mt0' > getB58String(peer: (Multiaddr | PeerInfo)): 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' > ((Multiaddr | PeerInfo))< / code >
< / div >
< / div >
< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > any< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'ispeerconnected' >
isPeerConnected
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/utils.js#L46-L48' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit/utils.js< / span >
< / a >
< / div >
< p > Checks if peer has an existing connection< / p >
< div class = 'pre p1 fill-light mt0' > isPeerConnected(peerId: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > String< / a > , swarm: Swarm): < 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' > (< 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' > swarm< / span > < code class = 'quiet' > (Swarm)< / 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/Boolean" > Boolean< / a > < / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'writeresponse' >
writeResponse
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/utils.js#L58-L65' >
2019-08-21 19:52:04 +02:00
< 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, cb: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > Function< / a > ): any< / 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 class = 'space-bottom0' >
< div >
< span class = 'code bold' > cb< / 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 > any< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'validateaddrs' >
validateAddrs
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/utils.js#L76-L100' >
2019-08-21 19:52:04 +02:00
< 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: CircuitRelay, streamHandler: StreamHandler, type: CircuitRelay.Type, cb: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > Function< / a > ): 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' > (CircuitRelay)< / code >
< / div >
< / div >
< 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' > type< / span > < code class = 'quiet' > (CircuitRelay.Type)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > cb< / 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 > any< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'listen' >
listen
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/listener.js#L36-L79' >
2019-08-21 19:52:04 +02:00
< 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(ma: Multiaddr, callback: < 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' > ma< / span > < code class = 'quiet' > (Multiaddr)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / 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 > void< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'close' >
close
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/listener.js#L87-L91' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/listener.js< / span >
< / a >
< / div >
< p > Remove swarm listener< / p >
< div class = 'pre p1 fill-light mt0' > close(cb: < 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' > cb< / 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 > void< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'getaddrs' >
getAddrs
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/listener.js#L110-L146' >
2019-08-21 19:52:04 +02:00
< 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(callback: < 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' > callback< / 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 > void< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'handle' >
handle
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/stop.js#L32-L53' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit/stop.js< / span >
< / a >
< / div >
< p > Handle the incoming STOP message< / p >
< div class = 'pre p1 fill-light mt0' > handle(msg: {}, sh: StreamHandler, callback: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > Function< / a > ): < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined" > undefined< / a > < / 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' > ({})< / code >
the parsed protobuf message
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > sh< / span > < code class = 'quiet' > (StreamHandler)< / code >
the stream handler wrapped connection
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > Function< / a > )< / code >
callback
< / 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/undefined" > undefined< / a > < / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'constructor' >
constructor
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/hop.js#L33-L40' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit/hop.js< / span >
< / a >
< / div >
< p > Construct a Circuit object< / p >
< p > This class will handle incoming circuit connections and
either start a relay or hand the relayed connection to
the swarm< / p >
< div class = 'pre p1 fill-light mt0' > constructor(swarm: Swarm, 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' > swarm< / span > < code class = 'quiet' > (Swarm)< / 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 >
< / div >
< / div >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'handle' >
handle
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/hop.js#L49-L141' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit/hop.js< / span >
< / a >
< / div >
< p > Handle the relay message< / p >
< div class = 'pre p1 fill-light mt0' > handle(message: CircuitRelay, sh: StreamHandler): any< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > message< / span > < code class = 'quiet' > (CircuitRelay)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > sh< / span > < code class = 'quiet' > (StreamHandler)< / code >
< / div >
< / div >
< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > any< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = '_connecttostop' >
_connectToStop
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/hop.js#L151-L172' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit/hop.js< / span >
< / a >
< / div >
< p > Connect to STOP< / p >
< div class = 'pre p1 fill-light mt0' > _connectToStop(peer: PeerInfo, srcSh: StreamHandler, callback: < 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' > peer< / span > < code class = 'quiet' > (PeerInfo)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > srcSh< / span > < code class = 'quiet' > (StreamHandler)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / 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 > void< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = '_negotiatestop' >
_negotiateStop
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/circuit/circuit/hop.js#L183-L212' >
2019-08-21 19:52:04 +02:00
< span > src/circuit/circuit/hop.js< / span >
< / a >
< / div >
< p > Negotiate STOP< / p >
< div class = 'pre p1 fill-light mt0' > _negotiateStop(dstSh: StreamHandler, srcSh: StreamHandler, message: CircuitRelay, callback: < 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' > dstSh< / span > < code class = 'quiet' > (StreamHandler)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > srcSh< / span > < code class = 'quiet' > (StreamHandler)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > message< / span > < code class = 'quiet' > (CircuitRelay)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / 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 > void< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'transportmanager' >
TransportManager
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/transport.js#L21-L227' >
2019-08-21 19:52:04 +02:00
< span > src/switch/transport.js< / span >
< / a >
< / div >
< p > Manages the transports for the switch. This simplifies dialing and listening across
multiple transports.< / p >
< div class = 'pre p1 fill-light mt0' > new TransportManager(_switch: any)< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > _switch< / 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 = 'transportmanagerdialables' >
< 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' > dialables(transport, multiaddrs, peerInfo)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/transport.js#L209-L226' >
2019-08-21 19:52:04 +02:00
< span > src/switch/transport.js< / span >
< / a >
< / div >
< p > For a given transport, return its multiaddrs that match the given multiaddrs< / p >
< div class = 'pre p1 fill-light mt0' > dialables(transport: Transport, multiaddrs: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > < Multiaddr>, peerInfo: PeerInfo): < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > < Multiaddr>< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< 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' > multiaddrs< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > < Multiaddr>)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > peerInfo< / span > < code class = 'quiet' > (PeerInfo)< / code >
Optional - a peer whose addresses should not be returned
< / 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 > < Multiaddr>< / code > :
< / section >
< / div >
< / div >
< / div >
< div class = 'py1 quiet mt1 prose-big' > Instance Members< / div >
< div class = "clearfix" >
< div class = 'border-bottom' id = 'transportmanageradd' >
< 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(key, transport)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/transport.js#L34-L44' >
2019-08-21 19:52:04 +02:00
< span > src/switch/transport.js< / span >
< / a >
< / div >
< p > Adds a < code > Transport< / code > to the list of transports on the switch, and assigns it to the given key< / 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): 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 >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > void< / code > :
< / section >
< / div >
< / div >
< div class = 'border-bottom' id = 'transportmanagerremove' >
< 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(key, callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/transport.js#L54-L65' >
2019-08-21 19:52:04 +02:00
< span > src/switch/transport.js< / span >
< / a >
< / div >
< p > Closes connections for the given transport key
and removes it from the switch.< / 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 > , callback: function (< 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' > 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' > callback< / span > < code class = 'quiet' > (function (< 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 = 'transportmanagerremoveall' >
< 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' > removeAll(callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/transport.js#L73-L81' >
2019-08-21 19:52:04 +02:00
< span > src/switch/transport.js< / span >
< / a >
< / div >
< p > Calls < code > remove< / code > on each transport the switch has< / p >
< div class = 'pre p1 fill-light mt0' > removeAll(callback: function (< 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' > callback< / span > < code class = 'quiet' > (function (< 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 = 'transportmanagerdial' >
< 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(key, peerInfo, callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/transport.js#L91-L112' >
2019-08-21 19:52:04 +02:00
< span > src/switch/transport.js< / span >
< / a >
< / div >
< p > For a given transport < code > key< / code > , dial to all that transport multiaddrs< / p >
< div class = 'pre p1 fill-light mt0' > dial(key: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > String< / a > , peerInfo: PeerInfo, callback: function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Connection)): 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 >
Key of the
< code > Transport< / code >
to dial
< / div >
< / div >
< 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' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , 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 = 'transportmanagerlisten' >
< 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(key, _options, handler, callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/transport.js#L124-L178' >
2019-08-21 19:52:04 +02:00
< span > src/switch/transport.js< / span >
< / a >
< / div >
< p > For a given Transport < code > key< / code > , listen on all multiaddrs in the switch's < code > _peerInfo< / code > .
If a < code > handler< / code > is not provided, the Switch's < code > protocolMuxer< / code > will be used.< / p >
< div class = 'pre p1 fill-light mt0' > listen(key: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > String< / a > , _options: any, handler: function (Connection), callback: function (< 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' > 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' > _options< / span > < code class = 'quiet' > (any)< / code >
Currently ignored
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > handler< / span > < code class = 'quiet' > (function (Connection))< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< 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 = 'transportmanagerclose' >
< 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(key, callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/transport.js#L187-L199' >
2019-08-21 19:52:04 +02:00
< span > src/switch/transport.js< / span >
< / a >
< / div >
< p > Closes the transport with the given key, by closing all of its listeners< / p >
< div class = 'pre p1 fill-light mt0' > close(key: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > String< / a > , callback: function (< 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' > 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' > callback< / span > < code class = 'quiet' > (function (< 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 >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'ouraddresses' >
ourAddresses
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/transport.js#L236-L249' >
2019-08-21 19:52:04 +02:00
< span > src/switch/transport.js< / span >
< / a >
< / div >
< p > Expand addresses in peer info into array of addresses with and without peer
ID suffix.< / p >
< div class = 'pre p1 fill-light mt0' > ourAddresses(peerInfo: PeerInfo): < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / 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' > peerInfo< / span > < code class = 'quiet' > (PeerInfo)< / code >
Our peer info object
< / 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 > < < 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 = 'getdestination' >
getDestination
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/transport.js#L264-L270' >
2019-08-21 19:52:04 +02:00
< span > src/switch/transport.js< / span >
< / a >
< / div >
< p > Get the destination address of a (possibly relay) multiaddr as a string< / p >
< div class = 'pre p1 fill-light mt0' > getDestination(addr: Multiaddr): < 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' > addr< / span > < code class = 'quiet' > (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/String" > String< / a > < / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'limitdialer' >
LimitDialer
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/limit-dialer/index.js#L13-L86' >
2019-08-21 19:52:04 +02:00
< span > src/switch/limit-dialer/index.js< / span >
< / a >
< / div >
< p > Track dials per peer and limited them.< / p >
< div class = 'pre p1 fill-light mt0' > new LimitDialer(perPeerLimit: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number" > number< / a > , dialTimeout: < 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' > perPeerLimit< / 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' > dialTimeout< / 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' > Instance Members< / div >
< div class = "clearfix" >
< div class = 'border-bottom' id = 'limitdialerdialmany' >
< 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' > dialMany(peer, transport, addrs, callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/limit-dialer/index.js#L36-L61' >
2019-08-21 19:52:04 +02:00
< span > src/switch/limit-dialer/index.js< / span >
< / a >
< / div >
< p > Dial a list of multiaddrs on the given transport.< / p >
< div class = 'pre p1 fill-light mt0' > dialMany(peer: PeerId, transport: SwarmTransport, addrs: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > < Multiaddr>, callback: function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Connection)): 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' > (PeerId)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > transport< / span > < code class = 'quiet' > (SwarmTransport)< / code >
< / div >
< / div >
< 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 > < Multiaddr>)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , 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 = 'limitdialerdialsingle' >
< 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' > dialSingle(peer, transport, addr, token, callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/limit-dialer/index.js#L73-L85' >
2019-08-21 19:52:04 +02:00
< span > src/switch/limit-dialer/index.js< / span >
< / a >
< / div >
< p > Dial a single multiaddr on the given transport.< / p >
< div class = 'pre p1 fill-light mt0' > dialSingle(peer: PeerId, transport: SwarmTransport, addr: Multiaddr, token: CancelToken, callback: function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Connection)): 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' > (PeerId)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > transport< / span > < code class = 'quiet' > (SwarmTransport)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > addr< / span > < code class = 'quiet' > (Multiaddr)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > token< / span > < code class = 'quiet' > (CancelToken)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Connection))< / 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 = 'dialqueue' >
DialQueue
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/limit-dialer/queue.js#L17-L107' >
2019-08-21 19:52:04 +02:00
< span > src/switch/limit-dialer/queue.js< / span >
< / a >
< / div >
< p > Queue up the amount of dials to a given peer.< / p >
< div class = 'pre p1 fill-light mt0' > new DialQueue(limit: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number" > number< / a > , dialTimeout: < 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' > limit< / 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' > dialTimeout< / 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' > Instance Members< / div >
< div class = "clearfix" >
< div class = 'border-bottom' id = 'dialqueuepush' >
< 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(transport, addr, token, callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/limit-dialer/queue.js#L104-L106' >
2019-08-21 19:52:04 +02:00
< span > src/switch/limit-dialer/queue.js< / span >
< / a >
< / div >
< p > Add new work to the queue.< / p >
< div class = 'pre p1 fill-light mt0' > push(transport: SwarmTransport, addr: Multiaddr, token: CancelToken, callback: function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Connection)): void< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > transport< / span > < code class = 'quiet' > (SwarmTransport)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > addr< / span > < code class = 'quiet' > (Multiaddr)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > token< / span > < code class = 'quiet' > (CancelToken)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Connection))< / 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 = 'mshandle' >
msHandle
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/utils.js#L11-L18' >
2019-08-21 19:52:04 +02:00
< span > src/switch/utils.js< / span >
< / a >
< / div >
< p > For a given multistream, registers to handle the given connection< / p >
< div class = 'pre p1 fill-light mt0' > msHandle(multistream: MultistreamDialer, connection: Connection): < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise" > Promise< / a > < / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > multistream< / span > < code class = 'quiet' > (MultistreamDialer)< / code >
< / div >
< / div >
< 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 > < / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'msselect' >
msSelect
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/utils.js#L26-L33' >
2019-08-21 19:52:04 +02:00
< span > src/switch/utils.js< / span >
< / a >
< / div >
< p > For a given multistream, selects the given protocol< / p >
< div class = 'pre p1 fill-light mt0' > msSelect(multistream: MultistreamDialer, protocol: < 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 > < / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > multistream< / span > < code class = 'quiet' > (MultistreamDialer)< / code >
< / div >
< / div >
< 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 = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise" > Promise< / a > < / code > :
Resolves the selected Connection
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'identifydialer' >
identifyDialer
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/utils.js#L42-L49' >
2019-08-21 19:52:04 +02:00
< span > src/switch/utils.js< / span >
< / a >
< / div >
< p > Runs identify for the given connection and verifies it against the
PeerInfo provided< / p >
< div class = 'pre p1 fill-light mt0' > identifyDialer(connection: Connection, cryptoPeerInfo: PeerInfo): < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise" > Promise< / a > < / 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 class = 'space-bottom0' >
< div >
< span class = 'code bold' > cryptoPeerInfo< / span > < code class = 'quiet' > (PeerInfo)< / code >
The PeerInfo determined during crypto exchange
< / 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 > < / code > :
Resolves {peerInfo, observedAddrs}
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'uniqueby' >
uniqueBy
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/utils.js#L58-L60' >
2019-08-21 19:52:04 +02:00
< span > src/switch/utils.js< / span >
< / a >
< / div >
< p > Get unique values from < code > arr< / code > using < code > getValue< / code > to determine
what is used for uniqueness< / p >
< div class = 'pre p1 fill-light mt0' > uniqueBy(arr: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > , getValue: function (value)): < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > < / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > arr< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > )< / code >
The array to get unique values for
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > getValue< / span > < code class = 'quiet' > (function (value))< / code >
The function to determine what is compared
< / 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 > < / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'connectionmanager' >
ConnectionManager
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/manager.js#L19-L287' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/manager.js< / span >
< / a >
< / div >
< p > Contains methods for binding handlers to the Switch
in order to better manage its connections.< / p >
< div class = 'pre p1 fill-light mt0' > new ConnectionManager(_switch: any)< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > _switch< / 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 = 'connectionmanageraddstreammuxer' >
< 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' > addStreamMuxer(muxer)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/manager.js#L150-L237' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/manager.js< / span >
< / a >
< / div >
< p > Adds a listener for the given < code > muxer< / code > and creates a handler for it
leveraging the Switch.protocolMuxer handler factory< / p >
< div class = 'pre p1 fill-light mt0' > addStreamMuxer(muxer: Muxer): void< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > muxer< / span > < code class = 'quiet' > (Muxer)< / code >
< / div >
< / div >
< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > void< / code > :
< / section >
< / div >
< / div >
< div class = 'border-bottom' id = 'connectionmanagercrypto' >
< 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' > crypto(tag, encrypt)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/manager.js#L247-L254' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/manager.js< / span >
< / a >
< / div >
< p > Adds the < code > encrypt< / code > handler for the given < code > tag< / code > and also sets the
Switch's crypto to passed < code > encrypt< / code > function< / p >
< div class = 'pre p1 fill-light mt0' > crypto(tag: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > String< / a > , encrypt: function (PeerID, Connection, PeerId, Callback)): void< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > tag< / 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' > encrypt< / span > < code class = 'quiet' > (function (PeerID, Connection, PeerId, Callback))< / code >
< / div >
< / div >
< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > void< / code > :
< / section >
< / div >
< / div >
< div class = 'border-bottom' id = 'connectionmanagerenablecircuitrelay' >
< 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' > enableCircuitRelay(config)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/manager.js#L263-L273' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/manager.js< / span >
< / a >
< / div >
< p > If config.enabled is true, a Circuit relay will be added to the
available Switch transports.< / p >
< div class = 'pre p1 fill-light mt0' > enableCircuitRelay(config: any): void< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > config< / 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 = 'connectionmanagerreuse' >
< 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' > reuse()< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/manager.js#L281-L286' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/manager.js< / span >
< / a >
< / div >
< p > Sets identify to true on the Switch and performs handshakes
for libp2p-identify leveraging the Switch's muxer.< / p >
< div class = 'pre p1 fill-light mt0' > reuse(): void< / 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 = 'connectionoptions' >
ConnectionOptions
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/index.js#L23-L30' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/index.js< / span >
< / a >
< / div >
< div class = 'pre p1 fill-light mt0' > ConnectionOptions< / 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' > _switch< / span > < code class = 'quiet' > (< a href = "#switch" > Switch< / a > )< / code >
: Our switch instance
< / div >
< div class = 'space-bottom0' >
< span class = 'code bold' > peerInfo< / span > < code class = 'quiet' > (PeerInfo)< / code >
: The PeerInfo of the peer to dial
< / div >
< div class = 'space-bottom0' >
< span class = 'code bold' > muxer< / span > < code class = 'quiet' > (Muxer)< / code >
: Optional - A muxed connection
< / div >
< div class = 'space-bottom0' >
< span class = 'code bold' > conn< / span > < code class = 'quiet' > (Connection)< / code >
: Optional - The base connection
< / div >
< div class = 'space-bottom0' >
< span class = 'code bold' > type< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > )< / code >
: Optional - identify the connection as incoming or outgoing. Defaults to out.
< / div >
< / div >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'connectionfsm' >
ConnectionFSM
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/index.js#L39-L493' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/index.js< / span >
< / a >
< / div >
< p > ConnectionFSM handles the complex logic of managing a connection
between peers. ConnectionFSM is internally composed of a state machine
to help improve the usability and debuggability of connections. The
state machine also helps to improve the ability to handle dial backoff,
coalescing dials and dial locks.< / p >
< div class = 'pre p1 fill-light mt0' > new ConnectionFSM(connectionOptions: < a href = "#connectionoptions" > ConnectionOptions< / a > )< / div >
< p >
Extends
BaseConnection
< / p >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > connectionOptions< / span > < code class = 'quiet' > (< a href = "#connectionoptions" > ConnectionOptions< / 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' > connectionOptions._switch< / span > < code class = 'quiet' > any< / code >
< / td >
< td class = 'break-word' > < span > < / span > < / td >
< / tr >
< tr >
< td class = 'break-word' > < span class = 'code bold' > connectionOptions.peerInfo< / span > < code class = 'quiet' > any< / code >
< / td >
< td class = 'break-word' > < span > < / span > < / td >
< / tr >
< tr >
< td class = 'break-word' > < span class = 'code bold' > connectionOptions.muxer< / span > < code class = 'quiet' > any< / code >
< / td >
< td class = 'break-word' > < span > < / span > < / td >
< / tr >
< tr >
< td class = 'break-word' > < span class = 'code bold' > connectionOptions.conn< / span > < code class = 'quiet' > any< / code >
< / td >
< td class = 'break-word' > < span > < / span > < / td >
< / tr >
< tr >
< td class = 'break-word' > < span class = 'code bold' > connectionOptions.type< / span > < code class = 'quiet' > any< / code >
(default < code > ' out' < / code > )
< / td >
< td class = 'break-word' > < span > < / span > < / td >
< / tr >
< / tbody >
< / table >
< / div >
< / div >
< div class = 'py1 quiet mt1 prose-big' > Instance Members< / div >
< div class = "clearfix" >
< div class = 'border-bottom' id = 'connectionfsmdial' >
< 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()< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/index.js#L149-L157' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/index.js< / span >
< / a >
< / div >
< p > Puts the state into dialing mode< / p >
< div class = 'pre p1 fill-light mt0' > dial(): void< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > void< / code > :
< / section >
< / div >
< / div >
< div class = 'border-bottom' id = 'connectionfsmshake' >
< 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' > shake(protocol, callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/index.js#L166-L184' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/index.js< / span >
< / a >
< / div >
< p > Initiates a handshake for the given protocol< / p >
< div class = 'pre p1 fill-light mt0' > shake(protocol: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > , callback: function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Connection)): void< / 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 >
The protocol to negotiate
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , 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 = 'connectionfsmupgrade' >
< 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' > upgrade()< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/index.js#L191-L193' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/index.js< / span >
< / a >
< / div >
< p > Puts the state into muxing mode< / p >
< div class = 'pre p1 fill-light mt0' > upgrade(): void< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > void< / code > :
< / section >
< / div >
< / div >
< div class = 'border-bottom' id = 'connectionfsm_ondialed' >
< 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' > _onDialed()< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/index.js#L258-L262' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/index.js< / span >
< / a >
< / div >
< p > Once a connection has been successfully dialed, the connection
will be privatized or encrypted depending on the presence of the
Switch.protector.< / p >
< div class = 'pre p1 fill-light mt0' > _onDialed(): void< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > void< / code > :
< / section >
< / div >
< / div >
< div class = 'border-bottom' id = 'connectionfsm_ondisconnecting' >
< 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' > _onDisconnecting()< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/index.js#L269-L298' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/index.js< / span >
< / a >
< / div >
< p > Event handler for disconnecting. Handles any needed cleanup< / p >
< div class = 'pre p1 fill-light mt0' > _onDisconnecting(): void< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > void< / code > :
< / section >
< / div >
< / div >
< div class = 'border-bottom' id = 'connectionfsm_didupgrade' >
< 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' > _didUpgrade(err)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/index.js#L438-L449' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/index.js< / span >
< / a >
< / div >
< p > Analyses the given error, if it exists, to determine where the state machine
needs to go.< / p >
< div class = 'pre p1 fill-light mt0' > _didUpgrade(err: < 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' > err< / 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 = 'connectionfsm_onstateerror' >
< 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' > _onStateError(err)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/index.js#L489-L492' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/index.js< / span >
< / a >
< / div >
< p > Event handler for state transition errors< / p >
< div class = 'pre p1 fill-light mt0' > _onStateError(err: < 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' > err< / 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 >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = '_dial' >
_dial
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/index.js#L24-L38' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/index.js< / span >
< / a >
< / div >
< div class = 'pre p1 fill-light mt0' > _dial(dialRequest: < a href = "#dialrequest" > DialRequest< / a > ): void< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > dialRequest< / span > < code class = 'quiet' > (< a href = "#dialrequest" > DialRequest< / 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' > dialRequest.peerInfo< / span > < code class = 'quiet' > any< / code >
< / td >
< td class = 'break-word' > < span > < / span > < / td >
< / tr >
< tr >
< td class = 'break-word' > < span class = 'code bold' > dialRequest.protocol< / span > < code class = 'quiet' > any< / code >
< / td >
< td class = 'break-word' > < span > < / span > < / td >
< / tr >
< tr >
< td class = 'break-word' > < span class = 'code bold' > dialRequest.options< / span > < code class = 'quiet' > any< / code >
< / td >
< td class = 'break-word' > < span > < / span > < / td >
< / tr >
< tr >
< td class = 'break-word' > < span class = 'code bold' > dialRequest.callback< / 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 > void< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'start' >
start
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/index.js#L45-L48' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/index.js< / span >
< / a >
< / div >
< p > Starts the < code > DialQueueManager< / code > < / p >
< div class = 'pre p1 fill-light mt0' > start(callback: < 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' > callback< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > function< / a > )< / code >
< / div >
< / div >
< / div >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'stop' >
stop
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/index.js#L56-L59' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/index.js< / span >
< / a >
< / div >
< p > Aborts all dials that are queued. This should
only be used when the Switch is being stopped< / p >
< div class = 'pre p1 fill-light mt0' > stop(callback: < 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' > callback< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > function< / a > )< / code >
< / div >
< / div >
< / div >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'cleardenylist' >
clearDenylist
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/index.js#L65-L67' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/index.js< / span >
< / a >
< / div >
< p > Clears the denylist for a given peer< / p >
< div class = 'pre p1 fill-light mt0' > clearDenylist(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 >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'connect' >
connect
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/index.js#L78-L85' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/index.js< / span >
< / a >
< / div >
< p > Attempts to establish a connection to the given < code > peerInfo< / code > at
a lower priority than a standard dial.< / p >
< div class = 'pre p1 fill-light mt0' > connect(peerInfo: PeerInfo, options: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object" > object< / a > , callback: function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , 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 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.useFSM< / 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 > Whether or not to return a
< code > ConnectionFSM< / code >
. Defaults to false.
< / span > < / td >
< / tr >
< tr >
< td class = 'break-word' > < span class = 'code bold' > options.priority< / 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 > Lowest priority goes first. Defaults to 20.
< / span > < / td >
< / tr >
< / tbody >
< / table >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Connection))< / code >
< / div >
< / div >
< / div >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'dial' >
dial
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/index.js#L94-L96' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/index.js< / span >
< / a >
< / div >
< p > Adds the dial request to the queue for the given < code > peerInfo< / code >
The request will be added with a high priority (10).< / p >
< div class = 'pre p1 fill-light mt0' > dial(peerInfo: PeerInfo, protocol: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > , callback: function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , 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 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 class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Connection))< / code >
< / div >
< / div >
< / div >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'dialfsm' >
dialFSM
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/index.js#L105-L107' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/index.js< / span >
< / a >
< / div >
< p > Behaves like dial, except it calls back with a ConnectionFSM< / p >
< div class = 'pre p1 fill-light mt0' > dialFSM(peerInfo: PeerInfo, protocol: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > , callback: function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , < a href = "#connectionfsm" > ConnectionFSM< / 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' > 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 = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , < a href = "#connectionfsm" > ConnectionFSM< / 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 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queueManager.js#L18-L26' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queueManager.js< / span >
< / a >
< / div >
< div class = 'pre p1 fill-light mt0' > new constructor(_switch: < a href = "#switch" > Switch< / a > )< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > _switch< / span > < code class = 'quiet' > (< a href = "#switch" > Switch< / a > )< / code >
< / div >
< / div >
< / div >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'start' >
start
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queueManager.js#L73-L75' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queueManager.js< / span >
< / a >
< / div >
< p > Allows the < code > DialQueueManager< / code > to execute dials< / 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 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queueManager.js#L83-L98' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queueManager.js< / span >
< / a >
< / div >
< p > Iterates over all items in the DialerQueue
and executes there callback with an error.< / p >
< p > This causes the entire DialerQueue to be drained< / 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 = 'add' >
add
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queueManager.js#L106-L151' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queueManager.js< / span >
< / a >
< / div >
< p > Adds the < code > dialRequest< / code > to the queue and ensures queue is running< / p >
< div class = 'pre p1 fill-light mt0' > add(dialRequest: < a href = "#dialrequest" > DialRequest< / a > ): void< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > dialRequest< / span > < code class = 'quiet' > (< a href = "#dialrequest" > DialRequest< / 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' > dialRequest.peerInfo< / span > < code class = 'quiet' > any< / code >
< / td >
< td class = 'break-word' > < span > < / span > < / td >
< / tr >
< tr >
< td class = 'break-word' > < span class = 'code bold' > dialRequest.protocol< / span > < code class = 'quiet' > any< / code >
< / td >
< td class = 'break-word' > < span > < / span > < / td >
< / tr >
< tr >
< td class = 'break-word' > < span class = 'code bold' > dialRequest.options< / span > < code class = 'quiet' > any< / code >
< / td >
< td class = 'break-word' > < span > < / span > < / td >
< / tr >
< tr >
< td class = 'break-word' > < span class = 'code bold' > dialRequest.callback< / 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 > void< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'run' >
run
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queueManager.js#L156-L184' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queueManager.js< / span >
< / a >
< / div >
< p > Will execute up to < code > MAX_PARALLEL_DIALS< / code > dials< / p >
< div class = 'pre p1 fill-light mt0' > run()< / div >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'cleardenylist' >
clearDenylist
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queueManager.js#L190-L194' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queueManager.js< / span >
< / a >
< / div >
< p > Will remove the < code > peerInfo< / code > from the dial denylist< / p >
< div class = 'pre p1 fill-light mt0' > clearDenylist(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 >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'getqueue' >
getQueue
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queueManager.js#L212-L217' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queueManager.js< / span >
< / a >
< / div >
< p > Returns the < code > Queue< / code > for the given < code > peerInfo< / code > < / p >
< div class = 'pre p1 fill-light mt0' > getQueue(peerInfo: PeerInfo): < a href = "#queue" > Queue< / 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 >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > < a href = "#queue" > Queue< / a > < / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'dialrequest' >
DialRequest
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queue.js#L11-L20' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queue.js< / span >
< / a >
< / div >
< p > Components required to execute a dial< / p >
< div class = 'pre p1 fill-light mt0' > DialRequest< / 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' > peerInfo< / span > < code class = 'quiet' > (PeerInfo)< / code >
: The peer to dial to
< / 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 >
: The protocol to create a stream for
< / div >
< div class = 'space-bottom0' >
< 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 >
< ul >
< li > < code > options.useFSM< / code > < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean" > boolean< / a >
< p > If < code > callback< / code > should return a ConnectionFSM< / p >
< / li >
< li > < code > options.priority< / code > < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number" > number< / a >
< p > The priority of the dial< / p >
< / li >
< / ul >
< / div >
< / div >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'newconnection' >
NewConnection
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queue.js#L22-L26' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queue.js< / span >
< / a >
< / div >
< div class = 'pre p1 fill-light mt0' > NewConnection< / 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' > connectionFSM< / span > < code class = 'quiet' > (< a href = "#connectionfsm" > ConnectionFSM< / a > )< / code >
< / div >
< div class = 'space-bottom0' >
< span class = 'code bold' > didCreate< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean" > boolean< / a > )< / code >
< / div >
< / div >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'createconnectionwithprotocol' >
createConnectionWithProtocol
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queue.js#L40-L52' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queue.js< / span >
< / a >
< / div >
< p > Attempts to create a new connection or stream (when muxed),
via negotiation of the given < code > protocol< / code > . If no < code > protocol< / code > is
provided, no action will be taken and < code > callback< / code > will be called
immediately with no error or values.< / p >
< div class = 'pre p1 fill-light mt0' > createConnectionWithProtocol(options: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object" > object< / a > ): 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.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 >
< tr >
< td class = 'break-word' > < span class = 'code bold' > options.connection< / span > < code class = 'quiet' > < a href = "#connectionfsm" > ConnectionFSM< / a > < / code >
< / td >
< td class = 'break-word' > < span > < / span > < / td >
< / tr >
< tr >
< td class = 'break-word' > < span class = 'code bold' > options.callback< / span > < code class = 'quiet' > function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Connection)< / code >
< / td >
< td class = 'break-word' > < span > < / span > < / td >
< / tr >
< / tbody >
< / table >
< / 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 = 'queue' >
Queue
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queue.js#L60-L279' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queue.js< / span >
< / a >
< / div >
< p > A convenience array wrapper for controlling
a per peer queue< / p >
< div class = 'pre p1 fill-light mt0' > new Queue(peerId: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > , _switch: < a href = "#switch" > Switch< / a > , onStopped: function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > )): < a href = "#queue" > Queue< / 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' > (< 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' > _switch< / span > < code class = 'quiet' > (< a href = "#switch" > Switch< / a > )< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > onStopped< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > ))< / code >
Called when the queue stops
< / div >
< / div >
< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > < a href = "#queue" > Queue< / a > < / code > :
< div class = 'py1 quiet mt1 prose-big' > Instance Members< / div >
< div class = "clearfix" >
< div class = 'border-bottom' id = 'queueadd' >
< 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(protocol, useFSM, callback)< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queue.js#L88-L93' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queue.js< / span >
< / a >
< / div >
< p > Adds the dial request to the queue. The queue is not automatically started< / p >
< div class = 'pre p1 fill-light mt0' > add(protocol: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > , useFSM: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean" > boolean< / a > , callback: function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Connection)): void< / 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 class = 'space-bottom0' >
< div >
< span class = 'code bold' > useFSM< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean" > boolean< / a > )< / code >
If callback should use a ConnectionFSM instead
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , 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 = 'queueisdialallowed' >
< 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' > isDialAllowed()< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queue.js#L99-L110' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queue.js< / span >
< / a >
< / div >
< p > Determines whether or not dialing is currently allowed< / p >
< div class = 'pre p1 fill-light mt0' > isDialAllowed(): < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean" > boolean< / a > < / 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 = 'queuestart' >
< 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' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queue.js#L117-L125' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queue.js< / span >
< / a >
< / div >
< p > Starts the queue. If the queue was started < code > true< / code > will be returned.
If the queue was already running < code > false< / code > is returned.< / p >
< div class = 'pre p1 fill-light mt0' > start(): < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean" > boolean< / a > < / 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 = 'queuestop' >
< 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' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queue.js#L130-L136' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queue.js< / span >
< / a >
< / div >
< p > Stops the queue< / p >
< div class = 'pre p1 fill-light mt0' > stop()< / div >
< / section >
< / div >
< / div >
< div class = 'border-bottom' id = 'queueabort' >
< 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' > abort()< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queue.js#L141-L147' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queue.js< / span >
< / a >
< / div >
< p > Stops the queue and errors the callback for each dial request< / p >
< div class = 'pre p1 fill-light mt0' > abort()< / div >
< / section >
< / div >
< / div >
< div class = 'border-bottom' id = 'queuedenylist' >
< 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' > denylist()< / span >
< / div >
< / div >
< div class = "clearfix display-none toggle-target" >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/dialer/queue.js#L153-L170' >
2019-08-21 19:52:04 +02:00
< span > src/switch/dialer/queue.js< / span >
< / a >
< / div >
< p > Marks the queue as denylisted. The queue will be immediately aborted.< / p >
< div class = 'pre p1 fill-light mt0' > denylist(): void< / 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 = 'transportkey' >
transportKey
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/handler.js#L17-L44' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/handler.js< / span >
< / a >
< / div >
< p > Takes a transport key and returns a connection handler function< / p >
< div class = 'pre p1 fill-light mt0' > transportKey< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > transportKey< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > )< / code >
The key of the transport to handle connections for
< / 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 >
A custom handler to use
< / div >
< / div >
< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > function (Connection)< / code > :
A connection handler function
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'conn' >
conn
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/handler.js#L24-L43' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/handler.js< / span >
< / a >
< / div >
< p > Takes a base connection and manages listening behavior< / p >
< div class = 'pre p1 fill-light mt0' > conn< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > conn< / span > < code class = 'quiet' > (Connection)< / code >
The connection to manage
< / 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 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/base.js#L23-L30' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/base.js< / span >
< / a >
< / div >
< p > Puts the state into its disconnecting flow< / p >
< div class = 'pre p1 fill-light mt0' > close(err: < 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' > err< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > )< / code >
Will be emitted if provided
< / 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 = 'getstate' >
getState
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/base.js#L45-L47' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/base.js< / span >
< / a >
< / div >
< p > Gets the current state of the connection< / p >
< div class = 'pre p1 fill-light mt0' > getState(): < 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/String" > string< / a > < / code > :
The current state of the connection
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'encrypt' >
encrypt
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/base.js#L54-L56' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/base.js< / span >
< / a >
< / div >
< p > Puts the state into encrypting mode< / p >
< div class = 'pre p1 fill-light mt0' > encrypt(): 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 = 'protect' >
protect
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/base.js#L63-L65' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/base.js< / span >
< / a >
< / div >
< p > Puts the state into privatizing mode< / p >
< div class = 'pre p1 fill-light mt0' > protect(): 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 = 'upgrade' >
upgrade
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/base.js#L72-L74' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/base.js< / span >
< / a >
< / div >
< p > Puts the state into muxing mode< / p >
< div class = 'pre p1 fill-light mt0' > upgrade(): 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 = '_ondisconnected' >
_onDisconnected
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/base.js#L82-L87' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/base.js< / span >
< / a >
< / div >
< p > Event handler for disconnected.< / p >
< div class = 'pre p1 fill-light mt0' > _onDisconnected(): 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 = '_onprivatized' >
_onPrivatized
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/connection/base.js#L95-L97' >
2019-08-21 19:52:04 +02:00
< span > src/switch/connection/base.js< / span >
< / a >
< / div >
< p > Event handler for privatized< / p >
< div class = 'pre p1 fill-light mt0' > _onPrivatized(): 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 = 'observe-connection' >
observe-connection
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/observe-connection.js#L18-L44' >
2019-08-21 19:52:04 +02:00
< span > src/switch/observe-connection.js< / span >
< / a >
< / div >
< p > Creates a pull stream to run the given Connection stream through
the given Observer. This provides a way to more easily monitor connections
and their metadata. A new Connection will be returned that contains
has the attached Observer.< / p >
< div class = 'pre p1 fill-light mt0' > observe-connection(transport: Transport, protocol: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String" > string< / a > , connection: Connection, observer: Observer): Connection< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< 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' > 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 = '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' > observer< / span > < code class = 'quiet' > (Observer)< / code >
< / div >
< / 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 = 'plaintext' >
plaintext
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/plaintext.js#L9-L20' >
2019-08-21 19:52:04 +02:00
< span > src/switch/plaintext.js< / span >
< / a >
< / div >
< p > An encryption stub in the instance that the default crypto
has not been overriden for the Switch< / p >
< div class = 'pre p1 fill-light mt0' > plaintext< / div >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'observer' >
observer
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/observer.js#L15-L48' >
2019-08-21 19:52:04 +02:00
< span > src/switch/observer.js< / span >
< / a >
< / div >
< p > Takes a Switch and returns an Observer that can be used in conjunction with
observe-connection.js. The returned Observer comes with < code > incoming< / code > and
< code > outgoing< / code > properties that can be used in pull streams to emit all metadata
for messages that pass through a Connection.< / p >
< div class = 'pre p1 fill-light mt0' > observer(swtch: < a href = "#switch" > Switch< / a > ): EventEmitter< / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > swtch< / span > < code class = 'quiet' > (< a href = "#switch" > Switch< / a > )< / code >
< / div >
< / div >
< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
< code > EventEmitter< / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = '' >
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/stats/index.js#L24-L27' >
2019-08-21 19:52:04 +02:00
< span > src/switch/stats/index.js< / span >
< / a >
< / div >
< p > Binds to message events on the given < code > observer< / code > to generate stats
based on the Peer, Protocol and Transport used for the message. Stat
events will be emitted via the < code > update< / code > event.< / p >
< div class = 'pre p1 fill-light mt0' > < / div >
< div class = 'py1 quiet mt1 prose-big' > Parameters< / div >
< div class = 'prose' >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > observer< / span > < code class = 'quiet' > (Observer)< / 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 = "#stats" > Stats< / a > < / code > :
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'stats' >
Stats
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/stats/stat.js#L14-L237' >
2019-08-21 19:52:04 +02:00
< span > src/switch/stats/stat.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 > < < 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 > < < 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' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/stats/stat.js#L49-L53' >
2019-08-21 19:52:04 +02:00
< span > src/switch/stats/stat.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' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/stats/stat.js#L61-L66' >
2019-08-21 19:52:04 +02:00
< span > src/switch/stats/stat.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' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/stats/stat.js#L73-L75' >
2019-08-21 19:52:04 +02:00
< span > src/switch/stats/stat.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 > < < 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' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/stats/stat.js#L82-L84' >
2019-08-21 19:52:04 +02:00
< span > src/switch/stats/stat.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 > < MovingAverage>< / 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' >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/stats/stat.js#L94-L97' >
2019-08-21 19:52:04 +02:00
< span > src/switch/stats/stat.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 = 'old-peers' >
old-peers
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/switch/stats/old-peers.js#L11-L15' >
2019-08-21 19:52:04 +02:00
< span > src/switch/stats/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 = 'findpeer' >
findPeer
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/peer-routing.js#L25-L57' >
2019-08-21 19:52:04 +02:00
< 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< / 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.maxTimeout< / 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 class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Result< < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > >))< / code >
< / 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 = 'findproviders' >
findProviders
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/content-routing.js#L28-L64' >
2019-08-21 19:52:04 +02:00
< span > src/content-routing.js< / span >
< / a >
< / div >
< p > Iterates over all content routers in series to find providers of the given key.
2018-11-16 14:12:15 +01:00
Once a content router succeeds, iteration will stop.< / p >
2019-08-21 19:52:04 +02:00
< div class = 'pre p1 fill-light mt0' > findProviders< / 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.maxTimeout< / 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 class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (function (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error" > Error< / a > , Result< < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array" > Array< / a > >))< / code >
< / 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 = 'provide' >
provide
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/content-routing.js#L74-L82' >
2019-08-21 19:52:04 +02:00
< span > src/content-routing.js< / span >
< / a >
< / div >
< p > Iterates over all content routers in parallel to notify it is
2018-11-16 14:12:15 +01:00
a provider of the given key.< / p >
2019-08-21 19:52:04 +02:00
< div class = 'pre p1 fill-light mt0' > provide< / 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' > callback< / span > < code class = 'quiet' > (function (< 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 >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'subscribe' >
subscribe
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/pubsub.js#L35-L63' >
2019-08-21 19:52:04 +02:00
< span > src/pubsub.js< / span >
< / a >
< / div >
< p > Subscribe the given handler to a pubsub topic< / p >
2019-09-24 14:11:13 +02:00
< 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 > , options: (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object" > object< / a > | null)?, callback: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > function< / a > ?): (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise" > Promise< / a > | void)< / div >
2019-08-21 19:52:04 +02:00
< 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 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 > | null)?)< / code >
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > function< / a > ?)< / code >
An optional callback
< / 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 > | void)< / code > :
A promise is returned if no callback is provided
< div class = 'py1 quiet mt1 prose-big' > Example< / div >
< p > < p > Subscribe a handler to a topic< / p >
< / p >
< pre class = 'p1 overflow-auto round fill-light' > < span class = "hljs-comment" > // `null` must be passed for options until subscribe is no longer using promisify< / span >
< span class = "hljs-keyword" > const< / span > handler = < span class = "hljs-function" > (< span class = "hljs-params" > message< / span > ) => < / span > { }
< span class = "hljs-keyword" > await< / span > libp2p.subscribe(topic, handler, < span class = "hljs-literal" > null< / span > )< / pre >
< p > < p > Use a callback instead of the Promise api< / p >
< / p >
< pre class = 'p1 overflow-auto round fill-light' > < span class = "hljs-comment" > // `options` may be passed or omitted when supplying a callback< / span >
< span class = "hljs-keyword" > const< / span > handler = < span class = "hljs-function" > (< span class = "hljs-params" > message< / span > ) => < / span > { }
libp2p.subscribe(topic, handler, callback)< / pre >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'unsubscribe' >
unsubscribe
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/pubsub.js#L87-L114' >
2019-08-21 19:52:04 +02:00
< span > src/pubsub.js< / span >
< / a >
< / div >
< p > Unsubscribes from a pubsub topic< / p >
2019-09-24 14:11:13 +02:00
< 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 > | null), callback: < a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > function< / a > ?): (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise" > Promise< / a > | void)< / div >
2019-08-21 19:52:04 +02:00
< 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 > | null))< / code >
The handler to unsubscribe from
< / div >
< / div >
< div class = 'space-bottom0' >
< div >
< span class = 'code bold' > callback< / span > < code class = 'quiet' > (< a href = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function" > function< / a > ?)< / code >
An optional callback
< / 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 > | void)< / code > :
A promise is returned if no callback is provided
< div class = 'py1 quiet mt1 prose-big' > Example< / div >
< p > < p > Unsubscribe a topic for all handlers< / p >
< / p >
< pre class = 'p1 overflow-auto round fill-light' > < span class = "hljs-comment" > // `null` must be passed until unsubscribe is no longer using promisify< / span >
< span class = "hljs-keyword" > await< / span > libp2p.unsubscribe(topic, < span class = "hljs-literal" > null< / span > )< / pre >
< p > < p > Unsubscribe a topic for 1 handler< / p >
< / p >
< pre class = 'p1 overflow-auto round fill-light' > < span class = "hljs-keyword" > await< / span > libp2p.unsubscribe(topic, handler)< / pre >
< p > < p > Use a callback instead of the Promise api< / p >
< / p >
< pre class = 'p1 overflow-auto round fill-light' > libp2p.unsubscribe(topic, handler, callback)< / pre >
< / section >
< section class = 'p2 mb2 clearfix bg-white minishadow' >
< div class = 'clearfix' >
< h3 class = 'fl m0' id = 'getpeerinfo' >
getPeerInfo
< / h3 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/get-peer-info.js#L17-L42' >
2019-08-21 19:52:04 +02:00
< span > src/get-peer-info.js< / span >
< / a >
< / div >
< p > Converts the given < code > peer< / code > to a < code > PeerInfo< / code > instance.
The < code > PeerBook< / code > will be checked for the resulting peer, and
the peer will be updated in the < code > PeerBook< / 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 > ), peerBook: PeerBook): 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' > peerBook< / span > < code class = 'quiet' > (PeerBook)< / 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 >
2019-09-24 14:11:13 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p/blob/b11c6fc7e93477f90667bf0734baec992d3d88c8/src/get-peer-info.js#L53-L71' >
2019-08-21 19:52:04 +02:00
< 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 > < 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 > < PeerInfo>< / code > :
< / section >
< / div >
< / div >
< script src = 'assets/anchor.js' > < / script >
< script src = 'assets/split.js' > < / script >
< script src = 'assets/site.js' > < / script >
< / body >
< / html >