mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-05-02 14:02:14 +00:00
18581 lines
387 KiB
HTML
18581 lines
387 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset='utf-8'>
|
|
<title>libp2p 0.29.0-rc.0 | Documentation</title>
|
|
<meta name='description' content='JavaScript implementation of libp2p, a modular peer to peer network stack'>
|
|
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
|
<link href='assets/bass.css' rel='stylesheet'>
|
|
<link href='assets/style.css' rel='stylesheet'>
|
|
<link href='assets/github.css' rel='stylesheet'>
|
|
<link href='assets/split.css' rel='stylesheet'>
|
|
</head>
|
|
<body class='documentation m0'>
|
|
<div class='flex'>
|
|
<div id='split-left' class='overflow-auto fs0 height-viewport-100'>
|
|
<div class='py1 px2'>
|
|
<h3 class='mb0 no-anchor'>libp2p</h3>
|
|
<div class='mb1'><code>0.29.0-rc.0</code></div>
|
|
<input
|
|
placeholder='Filter'
|
|
id='filter-input'
|
|
class='col12 block input'
|
|
spellcheck='false'
|
|
autocapitalize='off'
|
|
autocorrect='off'
|
|
type='text' />
|
|
<div id='toc'>
|
|
<ul class='list-reset h5 py1-ul'>
|
|
|
|
|
|
<li><a
|
|
href='#libp2p'
|
|
class=" toggle-sibling">
|
|
Libp2p
|
|
<span class='icon'>▸</span>
|
|
</a>
|
|
|
|
<div class='toggle-target display-none'>
|
|
|
|
<ul class='list-reset py1-ul pl1'>
|
|
<li class='h5'><span>Static members</span></li>
|
|
|
|
<li><a
|
|
href='#libp2pcreate'
|
|
class='regular pre-open'>
|
|
.create
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
<ul class='list-reset py1-ul pl1'>
|
|
<li class='h5'><span>Instance members</span></li>
|
|
|
|
<li><a
|
|
href='#libp2pemit'
|
|
class='regular pre-open'>
|
|
#emit
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#libp2pstart'
|
|
class='regular pre-open'>
|
|
#start
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#libp2pstop'
|
|
class='regular pre-open'>
|
|
#stop
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#libp2ploadkeychain'
|
|
class='regular pre-open'>
|
|
#loadKeychain
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#libp2pconnections'
|
|
class='regular pre-open'>
|
|
#connections
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#libp2pdial'
|
|
class='regular pre-open'>
|
|
#dial
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#libp2pdialprotocol'
|
|
class='regular pre-open'>
|
|
#dialProtocol
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#libp2pmultiaddrs'
|
|
class='regular pre-open'>
|
|
#multiaddrs
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#libp2phangup'
|
|
class='regular pre-open'>
|
|
#hangUp
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#libp2pping'
|
|
class='regular pre-open'>
|
|
#ping
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#libp2phandle'
|
|
class='regular pre-open'>
|
|
#handle
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#libp2punhandle'
|
|
class='regular pre-open'>
|
|
#unhandle
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#findpeer'
|
|
class="">
|
|
findPeer
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#findproviders'
|
|
class="">
|
|
findProviders
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#provide'
|
|
class="">
|
|
provide
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#put'
|
|
class="">
|
|
put
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#get'
|
|
class="">
|
|
get
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#getmany'
|
|
class="">
|
|
getMany
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#getpeer'
|
|
class="">
|
|
getPeer
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#addressmanager'
|
|
class=" toggle-sibling">
|
|
AddressManager
|
|
<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='#addressmanagergetlistenaddrs'
|
|
class='regular pre-open'>
|
|
#getListenAddrs
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#addressmanagergetannounceaddrs'
|
|
class='regular pre-open'>
|
|
#getAnnounceAddrs
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#addressmanagergetnoannounceaddrs'
|
|
class='regular pre-open'>
|
|
#getNoAnnounceAddrs
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</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='#connectionmanager_peervalues'
|
|
class='regular pre-open'>
|
|
#_peerValues
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#connectionmanagerconnections'
|
|
class='regular pre-open'>
|
|
#connections
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#connectionmanagersize'
|
|
class='regular pre-open'>
|
|
#size
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#connectionmanagerstart'
|
|
class='regular pre-open'>
|
|
#start
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#connectionmanagerstop'
|
|
class='regular pre-open'>
|
|
#stop
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#connectionmanager_close'
|
|
class='regular pre-open'>
|
|
#_close
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#connectionmanagersetpeervalue'
|
|
class='regular pre-open'>
|
|
#setPeerValue
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#connectionmanageronconnect'
|
|
class='regular pre-open'>
|
|
#onConnect
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#connectionmanagerondisconnect'
|
|
class='regular pre-open'>
|
|
#onDisconnect
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#connectionmanagerget'
|
|
class='regular pre-open'>
|
|
#get
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#connectionmanagergetall'
|
|
class='regular pre-open'>
|
|
#getAll
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#globalthis'
|
|
class="">
|
|
globalThis
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#summaryobject'
|
|
class="">
|
|
SummaryObject
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#latencymonitor'
|
|
class=" toggle-sibling">
|
|
LatencyMonitor
|
|
<span class='icon'>▸</span>
|
|
</a>
|
|
|
|
<div class='toggle-target display-none'>
|
|
|
|
|
|
<ul class='list-reset py1-ul pl1'>
|
|
<li class='h5'><span>Instance members</span></li>
|
|
|
|
<li><a
|
|
href='#latencymonitorgetsummary'
|
|
class='regular pre-open'>
|
|
#getSummary
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#'
|
|
class="">
|
|
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#visibilitychangeemitter'
|
|
class="">
|
|
VisibilityChangeEmitter
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#isvisible'
|
|
class="">
|
|
isVisible
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#constructor'
|
|
class="">
|
|
constructor
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#dial'
|
|
class="">
|
|
dial
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#createlistener'
|
|
class="">
|
|
createListener
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#filter'
|
|
class="">
|
|
filter
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#index'
|
|
class=" toggle-sibling">
|
|
index
|
|
<span class='icon'>▸</span>
|
|
</a>
|
|
|
|
<div class='toggle-target display-none'>
|
|
|
|
<ul class='list-reset py1-ul pl1'>
|
|
<li class='h5'><span>Static members</span></li>
|
|
|
|
<li><a
|
|
href='#indexmulticodecs'
|
|
class='regular pre-open'>
|
|
.multicodecs
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#listener'
|
|
class=" toggle-sibling">
|
|
listener
|
|
<span class='icon'>▸</span>
|
|
</a>
|
|
|
|
<div class='toggle-target display-none'>
|
|
|
|
<ul class='list-reset py1-ul pl1'>
|
|
<li class='h5'><span>Static members</span></li>
|
|
|
|
<li><a
|
|
href='#listenerlisten'
|
|
class='regular pre-open'>
|
|
.listen
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#listenerclose'
|
|
class='regular pre-open'>
|
|
.close
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#listenergetaddrs'
|
|
class='regular pre-open'>
|
|
.getAddrs
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#hop'
|
|
class="">
|
|
hop
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#writeresponse'
|
|
class="">
|
|
writeResponse
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#validateaddrs'
|
|
class="">
|
|
validateAddrs
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#constructor'
|
|
class="">
|
|
constructor
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#read'
|
|
class="">
|
|
read
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#write'
|
|
class="">
|
|
write
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#rest'
|
|
class="">
|
|
rest
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#close'
|
|
class="">
|
|
close
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#constructor'
|
|
class="">
|
|
constructor
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#destroy'
|
|
class="">
|
|
destroy
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#connecttopeer'
|
|
class="">
|
|
connectToPeer
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#_createdialtarget'
|
|
class="">
|
|
_createDialTarget
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#_creatependingdial'
|
|
class="">
|
|
_createPendingDial
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#constructor'
|
|
class="">
|
|
constructor
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#run'
|
|
class="">
|
|
run
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#keyinfo'
|
|
class="">
|
|
KeyInfo
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#keychain'
|
|
class=" toggle-sibling">
|
|
Keychain
|
|
<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='#keychaingenerateoptions'
|
|
class='regular pre-open'>
|
|
.generateOptions
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#keychainoptions'
|
|
class='regular pre-open'>
|
|
.options
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
<ul class='list-reset py1-ul pl1'>
|
|
<li class='h5'><span>Instance members</span></li>
|
|
|
|
<li><a
|
|
href='#keychaincms'
|
|
class='regular pre-open'>
|
|
#cms
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#keychaincreatekey'
|
|
class='regular pre-open'>
|
|
#createKey
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#keychainlistkeys'
|
|
class='regular pre-open'>
|
|
#listKeys
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#keychainfindkeybyid'
|
|
class='regular pre-open'>
|
|
#findKeyById
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#keychainfindkeybyname'
|
|
class='regular pre-open'>
|
|
#findKeyByName
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#keychainremovekey'
|
|
class='regular pre-open'>
|
|
#removeKey
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#keychainrenamekey'
|
|
class='regular pre-open'>
|
|
#renameKey
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#keychainexportkey'
|
|
class='regular pre-open'>
|
|
#exportKey
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#keychainimportkey'
|
|
class='regular pre-open'>
|
|
#importKey
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#cms'
|
|
class=" toggle-sibling">
|
|
CMS
|
|
<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='#cmsencrypt'
|
|
class='regular pre-open'>
|
|
#encrypt
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#cmsdecrypt'
|
|
class='regular pre-open'>
|
|
#decrypt
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#certificateforkey'
|
|
class="">
|
|
certificateForKey
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#findasync'
|
|
class="">
|
|
findAsync
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#constructor'
|
|
class="">
|
|
constructor
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#start'
|
|
class="">
|
|
start
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#stop'
|
|
class="">
|
|
stop
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#global'
|
|
class="">
|
|
global
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#peers'
|
|
class="">
|
|
peers
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#forpeer'
|
|
class="">
|
|
forPeer
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#protocols'
|
|
class="">
|
|
protocols
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#forprotocol'
|
|
class="">
|
|
forProtocol
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#onpeerdisconnected'
|
|
class="">
|
|
onPeerDisconnected
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#updateplaceholder'
|
|
class="">
|
|
updatePlaceholder
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#trackstream'
|
|
class="">
|
|
trackStream
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#mergestats'
|
|
class="">
|
|
mergeStats
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#old-peers'
|
|
class="">
|
|
old-peers
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#stats'
|
|
class=" toggle-sibling">
|
|
Stats
|
|
<span class='icon'>▸</span>
|
|
</a>
|
|
|
|
<div class='toggle-target display-none'>
|
|
|
|
|
|
<ul class='list-reset py1-ul pl1'>
|
|
<li class='h5'><span>Instance members</span></li>
|
|
|
|
<li><a
|
|
href='#statsstart'
|
|
class='regular pre-open'>
|
|
#start
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#statsstop'
|
|
class='regular pre-open'>
|
|
#stop
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#statssnapshot'
|
|
class='regular pre-open'>
|
|
#snapshot
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#statsmovingaverages'
|
|
class='regular pre-open'>
|
|
#movingAverages
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#statstojson'
|
|
class='regular pre-open'>
|
|
#toJSON
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#statspush'
|
|
class='regular pre-open'>
|
|
#push
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#constructor'
|
|
class="">
|
|
constructor
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#add'
|
|
class="">
|
|
add
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#close'
|
|
class="">
|
|
close
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#dial'
|
|
class="">
|
|
dial
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#getaddrs'
|
|
class="">
|
|
getAddrs
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#gettransports'
|
|
class="">
|
|
getTransports
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#transportformultiaddr'
|
|
class="">
|
|
transportForMultiaddr
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#listen'
|
|
class="">
|
|
listen
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#remove'
|
|
class="">
|
|
remove
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#removeall'
|
|
class="">
|
|
removeAll
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#fault_tolerance'
|
|
class="">
|
|
FAULT_TOLERANCE
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#upgrader'
|
|
class=" toggle-sibling">
|
|
Upgrader
|
|
<span class='icon'>▸</span>
|
|
</a>
|
|
|
|
<div class='toggle-target display-none'>
|
|
|
|
|
|
<ul class='list-reset py1-ul pl1'>
|
|
<li class='h5'><span>Instance members</span></li>
|
|
|
|
<li><a
|
|
href='#upgraderupgradeinbound'
|
|
class='regular pre-open'>
|
|
#upgradeInbound
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#upgraderupgradeoutbound'
|
|
class='regular pre-open'>
|
|
#upgradeOutbound
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#upgrader'
|
|
class=" toggle-sibling">
|
|
Upgrader
|
|
<span class='icon'>▸</span>
|
|
</a>
|
|
|
|
<div class='toggle-target display-none'>
|
|
|
|
|
|
<ul class='list-reset py1-ul pl1'>
|
|
<li class='h5'><span>Instance members</span></li>
|
|
|
|
<li><a
|
|
href='#upgraderupgradeinbound'
|
|
class='regular pre-open'>
|
|
#upgradeInbound
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#upgraderupgradeoutbound'
|
|
class='regular pre-open'>
|
|
#upgradeOutbound
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#peerstore'
|
|
class=" toggle-sibling">
|
|
PeerStore
|
|
<span class='icon'>▸</span>
|
|
</a>
|
|
|
|
<div class='toggle-target display-none'>
|
|
|
|
|
|
<ul class='list-reset py1-ul pl1'>
|
|
<li class='h5'><span>Instance members</span></li>
|
|
|
|
<li><a
|
|
href='#peerstoreaddressbook'
|
|
class='regular pre-open'>
|
|
#addressBook
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#peerstorekeybook'
|
|
class='regular pre-open'>
|
|
#keyBook
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#peerstoremetadatabook'
|
|
class='regular pre-open'>
|
|
#metadataBook
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#peerstoreprotobook'
|
|
class='regular pre-open'>
|
|
#protoBook
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#peerstorestart'
|
|
class='regular pre-open'>
|
|
#start
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#peerstorestop'
|
|
class='regular pre-open'>
|
|
#stop
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#peerstorepeers'
|
|
class='regular pre-open'>
|
|
#peers
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#peerstoredelete'
|
|
class='regular pre-open'>
|
|
#delete
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#peerstoreget'
|
|
class='regular pre-open'>
|
|
#get
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#addressbook'
|
|
class=" toggle-sibling">
|
|
AddressBook
|
|
<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='#addressbookdata'
|
|
class='regular pre-open'>
|
|
#data
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#addressbookconsumepeerrecord'
|
|
class='regular pre-open'>
|
|
#consumePeerRecord
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#addressbookgetrawenvelope'
|
|
class='regular pre-open'>
|
|
#getRawEnvelope
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#addressbookgetpeerrecord'
|
|
class='regular pre-open'>
|
|
#getPeerRecord
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#addressbookset'
|
|
class='regular pre-open'>
|
|
#set
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#addressbookadd'
|
|
class='regular pre-open'>
|
|
#add
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#addressbookget'
|
|
class='regular pre-open'>
|
|
#get
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#addressbookgetmultiaddrsforpeer'
|
|
class='regular pre-open'>
|
|
#getMultiaddrsForPeer
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#eventtransformer'
|
|
class="">
|
|
eventTransformer
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#eventtransformer'
|
|
class="">
|
|
eventTransformer
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#book'
|
|
class=" toggle-sibling">
|
|
Book
|
|
<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='#bookdata'
|
|
class='regular pre-open'>
|
|
#data
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#bookset'
|
|
class='regular pre-open'>
|
|
#set
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#bookget'
|
|
class='regular pre-open'>
|
|
#get
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#bookdelete'
|
|
class='regular pre-open'>
|
|
#delete
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#keybook'
|
|
class=" toggle-sibling">
|
|
KeyBook
|
|
<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='#keybookdata'
|
|
class='regular pre-open'>
|
|
#data
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#keybookset'
|
|
class='regular pre-open'>
|
|
#set
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#keybookget'
|
|
class='regular pre-open'>
|
|
#get
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#metadatabook'
|
|
class=" toggle-sibling">
|
|
MetadataBook
|
|
<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='#metadatabookdata'
|
|
class='regular pre-open'>
|
|
#data
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#metadatabookset'
|
|
class='regular pre-open'>
|
|
#set
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#metadatabook_setvalue'
|
|
class='regular pre-open'>
|
|
#_setValue
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#metadatabookget'
|
|
class='regular pre-open'>
|
|
#get
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#metadatabookgetvalue'
|
|
class='regular pre-open'>
|
|
#getValue
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#metadatabookdelete'
|
|
class='regular pre-open'>
|
|
#delete
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#metadatabookdeletevalue'
|
|
class='regular pre-open'>
|
|
#deleteValue
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#eventproperty'
|
|
class="">
|
|
eventProperty
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#protobook'
|
|
class=" toggle-sibling">
|
|
ProtoBook
|
|
<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='#protobookdata'
|
|
class='regular pre-open'>
|
|
#data
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#protobookset'
|
|
class='regular pre-open'>
|
|
#set
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#protobookadd'
|
|
class='regular pre-open'>
|
|
#add
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#subscribe'
|
|
class="">
|
|
subscribe
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#unsubscribe'
|
|
class="">
|
|
unsubscribe
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#persistentpeerstore'
|
|
class=" toggle-sibling">
|
|
PersistentPeerStore
|
|
<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='#persistentpeerstore_datastore'
|
|
class='regular pre-open'>
|
|
#_datastore
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#persistentpeerstore_dirtypeers'
|
|
class='regular pre-open'>
|
|
#_dirtyPeers
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#persistentpeerstore_dirtymetadata'
|
|
class='regular pre-open'>
|
|
#_dirtyMetadata
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#persistentpeerstorestart'
|
|
class='regular pre-open'>
|
|
#start
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#registrar'
|
|
class=" toggle-sibling">
|
|
Registrar
|
|
<span class='icon'>▸</span>
|
|
</a>
|
|
|
|
<div class='toggle-target display-none'>
|
|
|
|
|
|
<ul class='list-reset py1-ul pl1'>
|
|
<li class='h5'><span>Instance members</span></li>
|
|
|
|
<li><a
|
|
href='#registrartopologies'
|
|
class='regular pre-open'>
|
|
#topologies
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#registrargetconnection'
|
|
class='regular pre-open'>
|
|
#getConnection
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#registrarregister'
|
|
class='regular pre-open'>
|
|
#register
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#registrarunregister'
|
|
class='regular pre-open'>
|
|
#unregister
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#registrar_ondisconnect'
|
|
class='regular pre-open'>
|
|
#_onDisconnect
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#ping'
|
|
class="">
|
|
ping
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#mount'
|
|
class="">
|
|
mount
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#unmount'
|
|
class="">
|
|
unmount
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#constructor'
|
|
class="">
|
|
constructor
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#peerstore'
|
|
class="">
|
|
peerStore
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#connectionmanager'
|
|
class="">
|
|
connectionManager
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#peerid'
|
|
class="">
|
|
peerId
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#_libp2p'
|
|
class="">
|
|
_libp2p
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#push'
|
|
class="">
|
|
push
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#pushtopeerstore'
|
|
class="">
|
|
pushToPeerStore
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#identify'
|
|
class="">
|
|
identify
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#handlemessage'
|
|
class="">
|
|
handleMessage
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#_getselfpeerrecord'
|
|
class="">
|
|
_getSelfPeerRecord
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#getcleanmultiaddr'
|
|
class="">
|
|
getCleanMultiaddr
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#envelope'
|
|
class=" toggle-sibling">
|
|
Envelope
|
|
<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='#envelopecreatefromprotobuf'
|
|
class='regular pre-open'>
|
|
.createFromProtobuf
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#envelopeseal'
|
|
class='regular pre-open'>
|
|
.seal
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#envelopeopenandcertify'
|
|
class='regular pre-open'>
|
|
.openAndCertify
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
<ul class='list-reset py1-ul pl1'>
|
|
<li class='h5'><span>Instance members</span></li>
|
|
|
|
<li><a
|
|
href='#envelopemarshal'
|
|
class='regular pre-open'>
|
|
#marshal
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#envelopeequals'
|
|
class='regular pre-open'>
|
|
#equals
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#envelopevalidate'
|
|
class='regular pre-open'>
|
|
#validate
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#formatsignaturepayload'
|
|
class="">
|
|
formatSignaturePayload
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#peerrecord'
|
|
class=" toggle-sibling">
|
|
PeerRecord
|
|
<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='#peerrecordcreatefromprotobuf'
|
|
class='regular pre-open'>
|
|
.createFromProtobuf
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
<ul class='list-reset py1-ul pl1'>
|
|
<li class='h5'><span>Instance members</span></li>
|
|
|
|
<li><a
|
|
href='#peerrecordmarshal'
|
|
class='regular pre-open'>
|
|
#marshal
|
|
</a></li>
|
|
|
|
<li><a
|
|
href='#peerrecordequals'
|
|
class='regular pre-open'>
|
|
#equals
|
|
</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</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'>
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='libp2p'>
|
|
Libp2p
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/index.js#L42-L584'>
|
|
<span>src/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>new Libp2p(_options: any)</div>
|
|
|
|
|
|
<p>
|
|
Extends
|
|
|
|
EventEmitter
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>_options</span> <code class='quiet'>(any)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Static Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='libp2pcreate'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>create(options)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/index.js#L592-L601'>
|
|
<span>src/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Like <code>new Libp2p(options)</code> except it will create a <code>PeerId</code>
|
|
instance if one is not provided in options.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>create(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>): <a href="#libp2p">Libp2p</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>
|
|
= <code>{}</code>)</code>
|
|
Libp2p configuration options
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#libp2p">Libp2p</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='libp2pemit'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>emit(eventName, args)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/index.js#L213-L219'>
|
|
<span>src/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Overrides EventEmitter.emit to conditionally emit errors
|
|
if there is a handler. If not, errors will be logged.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>emit(eventName: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, args: ...any): void</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>eventName</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>args</span> <code class='quiet'>(...any)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>void</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='libp2pstart'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>start()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/index.js#L226-L239'>
|
|
<span>src/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Starts the libp2p node and all its subsystems</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>start(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><void></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><void></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='libp2pstop'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>stop()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/index.js#L246-L279'>
|
|
<span>src/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Stop the libp2p node by closing its listeners and open connections</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>stop(): void</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>void</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='libp2ploadkeychain'>
|
|
<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'>loadKeychain()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/index.js#L287-L293'>
|
|
<span>src/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Load keychain keys from the datastore.
|
|
Imports the private key as 'self', if needed.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>loadKeychain(): void</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>void</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='libp2pconnections'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>connections</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/index.js#L304-L306'>
|
|
<span>src/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Gets a Map of the current connections. The keys are the stringified
|
|
<code>PeerId</code> of the peer. The value is an array of Connections to that peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>connections</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map">Map</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Connection>></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='libp2pdial'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>dial(peer, options)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/index.js#L316-L318'>
|
|
<span>src/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Dials to the provided peer. If successful, the known metadata of the
|
|
peer will be added to the nodes <code>peerStore</code></p>
|
|
|
|
<div class='pre p1 fill-light mt0'>dial(peer: (PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>), options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peer</span> <code class='quiet'>((PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
|
|
The peer to dial
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.signal</span> <code class='quiet'>AbortSignal?</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='libp2pdialprotocol'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>dialProtocol(peer, protocols, options)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/index.js#L331-L347'>
|
|
<span>src/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Dials to the provided peer and handshakes with the given protocol.
|
|
If successful, the known metadata of the peer will be added to the nodes <code>peerStore</code>,
|
|
and the <code>Connection</code> will be returned</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>dialProtocol(peer: (PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>), protocols: (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>), options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><(Connection | any)></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peer</span> <code class='quiet'>((PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
|
|
The peer to dial
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>protocols</span> <code class='quiet'>((<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.signal</span> <code class='quiet'>AbortSignal?</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><(Connection | any)></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='libp2pmultiaddrs'>
|
|
<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'>multiaddrs</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/index.js#L355-L375'>
|
|
<span>src/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get peer advertising multiaddrs by concating the addresses used
|
|
by transports to listen with the announce addresses.
|
|
Duplicated addresses and noAnnounce addresses are filtered out.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>multiaddrs</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 class='border-bottom' id='libp2phangup'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>hangUp(peer)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/index.js#L382-L396'>
|
|
<span>src/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Disconnects all connections to the given <code>peer</code></p>
|
|
|
|
<div class='pre p1 fill-light mt0'>hangUp(peer: (PeerId | multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><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 | multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
|
|
the peer to close connections to
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><void></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='libp2pping'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>ping(peer)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/index.js#L403-L412'>
|
|
<span>src/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Pings the given peer in order to obtain the operation latency.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>ping(peer: (PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peer</span> <code class='quiet'>((PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
|
|
The peer to ping
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='libp2phandle'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>handle(protocols, handler)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/index.js#L419-L429'>
|
|
<span>src/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Registers the <code>handler</code> for each protocol</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>handle(protocols: (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>), handler: function ({connection: any, stream: any, protocol: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}))</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>protocols</span> <code class='quiet'>((<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>handler</span> <code class='quiet'>(function ({connection: any, stream: any, protocol: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>}))</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='libp2punhandle'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>unhandle(protocols)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/index.js#L436-L446'>
|
|
<span>src/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Removes the handler for each protocol. The protocol
|
|
will no longer be supported on streams.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>unhandle(protocols: (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>protocols</span> <code class='quiet'>((<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='findpeer'>
|
|
findPeer
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-routing.js#L23-L38'>
|
|
<span>src/peer-routing.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Iterates over all peer routers in series to find the given peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>findPeer(id: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><{id: PeerId, multiaddrs: <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'>id</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
|
|
The id of the peer to find
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.timeout</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>?</code>
|
|
</td>
|
|
<td class='break-word'><span>How long the query should run
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><{id: PeerId, multiaddrs: <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='findproviders'>
|
|
findProviders
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/content-routing.js#L29-L48'>
|
|
<span>src/content-routing.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Iterates over all content routers in series to find providers of the given key.
|
|
Once a content router succeeds, iteration will stop.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>findProviders(key: CID, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?): AsyncIterable<{id: PeerId, multiaddrs: <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'>key</span> <code class='quiet'>(CID)</code>
|
|
The CID key of the content to find
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.timeout</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>?</code>
|
|
</td>
|
|
<td class='break-word'><span>How long the query should run
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.maxNumProviders</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>?</code>
|
|
</td>
|
|
<td class='break-word'><span>maximum number of providers to find
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>AsyncIterable<{id: PeerId, multiaddrs: <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='provide'>
|
|
provide
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/content-routing.js#L57-L63'>
|
|
<span>src/content-routing.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Iterates over all content routers in parallel to notify it is
|
|
a provider of the given key.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>provide(key: CID): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><void></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>key</span> <code class='quiet'>(CID)</code>
|
|
The CID key of the content to find
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><void></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='put'>
|
|
put
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/content-routing.js#L73-L79'>
|
|
<span>src/content-routing.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Store the given key/value pair in the DHT.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>put(key: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>, value: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><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/Uint8Array">Uint8Array</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>value</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?)</code>
|
|
put options
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.minPeers</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>?</code>
|
|
</td>
|
|
<td class='break-word'><span>minimum number of peers required to successfully put
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><void></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='get'>
|
|
get
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/content-routing.js#L89-L95'>
|
|
<span>src/content-routing.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get the value to the given key.
|
|
Times out after 1 minute by default.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>get(key: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><{from: PeerId, val: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>}></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>key</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?)</code>
|
|
get options
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.timeout</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>?</code>
|
|
</td>
|
|
<td class='break-word'><span>optional timeout (default: 60000)
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><{from: PeerId, val: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>}></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='getmany'>
|
|
getMany
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/content-routing.js#L105-L111'>
|
|
<span>src/content-routing.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get the <code>n</code> values to the given key without sorting.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getMany(key: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>, nVals: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><{from: PeerId, val: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>}>></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>key</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>nVals</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?)</code>
|
|
get options
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.timeout</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>?</code>
|
|
</td>
|
|
<td class='break-word'><span>optional timeout (default: 60000)
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><{from: PeerId, val: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>}>></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='getpeer'>
|
|
getPeer
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/get-peer.js#L16-L38'>
|
|
<span>src/get-peer.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Converts the given <code>peer</code> to a <code>Peer</code> object.
|
|
If a multiaddr is received, the addressBook is updated.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getPeer(peer: (PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>), peerStore: <a href="#peerstore">PeerStore</a>): {id: PeerId, multiaddrs: <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'>peer</span> <code class='quiet'>((PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerStore</span> <code class='quiet'>(<a href="#peerstore">PeerStore</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>{id: PeerId, multiaddrs: <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='addressmanager'>
|
|
AddressManager
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/address-manager/index.js#L16-L53'>
|
|
<span>src/address-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Responsible for managing this peers addresses.
|
|
Peers can specify their listen, announce and noAnnounce addresses.
|
|
The listen addresses will be used by the libp2p transports to listen for new connections,
|
|
while the announce an noAnnounce addresses will be combined with the listen addresses for
|
|
address adverstising to other peers in the network.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new AddressManager($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>
|
|
= <code>{}</code>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.listen</span> <code class='quiet'>any</code>
|
|
|
|
(default <code>[]</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.announce</span> <code class='quiet'>any</code>
|
|
|
|
(default <code>[]</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.noAnnounce</span> <code class='quiet'>any</code>
|
|
|
|
(default <code>[]</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='addressmanagergetlistenaddrs'>
|
|
<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'>getListenAddrs()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/address-manager/index.js#L34-L36'>
|
|
<span>src/address-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get peer listen multiaddrs.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getListenAddrs(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='addressmanagergetannounceaddrs'>
|
|
<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'>getAnnounceAddrs()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/address-manager/index.js#L42-L44'>
|
|
<span>src/address-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get peer announcing multiaddrs.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getAnnounceAddrs(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='addressmanagergetnoannounceaddrs'>
|
|
<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'>getNoAnnounceAddrs()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/address-manager/index.js#L50-L52'>
|
|
<span>src/address-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get peer noAnnouncing multiaddrs.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getNoAnnounceAddrs(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='connectionmanager'>
|
|
ConnectionManager
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/index.js#L38-L353'>
|
|
<span>src/connection-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Responsible for managing known connections.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new ConnectionManager(libp2p: <a href="#libp2p">Libp2p</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
|
|
|
|
|
|
<p>
|
|
Extends
|
|
|
|
EventEmitter
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>libp2p</span> <code class='quiet'>(<a href="#libp2p">Libp2p</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='connectionmanager_peervalues'>
|
|
<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'>_peerValues</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/index.js#L74-L74'>
|
|
<span>src/connection-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Map of peer identifiers to their peer value for pruning connections.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>_peerValues</div>
|
|
|
|
<p>
|
|
Type:
|
|
<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>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='connectionmanagerconnections'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>connections</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/index.js#L80-L80'>
|
|
<span>src/connection-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Map of connections per peer</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>connections</div>
|
|
|
|
<p>
|
|
Type:
|
|
<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map">Map</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><conn>>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='connectionmanagersize'>
|
|
<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'>size</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/index.js#L92-L95'>
|
|
<span>src/connection-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get current number of open connections.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>size</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='connectionmanagerstart'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>start()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/index.js#L101-L118'>
|
|
<span>src/connection-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Starts the Connection Manager. If Metrics are not enabled on libp2p
|
|
only event loop and connection limits will be monitored.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>start()</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='connectionmanagerstop'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>stop()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/index.js#L124-L132'>
|
|
<span>src/connection-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Stops the Connection Manager</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>stop()</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='connectionmanager_close'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>_close()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/index.js#L138-L149'>
|
|
<span>src/connection-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Cleans up the connections</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>_close()</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='connectionmanagersetpeervalue'>
|
|
<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'>setPeerValue(peerId, value)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/index.js#L157-L165'>
|
|
<span>src/connection-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Sets the value of the given peer. Peers with lower values
|
|
will be disconnected first.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>setPeerValue(peerId: PeerId, value: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>value</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)</code>
|
|
A number between 0 and 1
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='connectionmanageronconnect'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>onConnect(connection)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/index.js#L188-L207'>
|
|
<span>src/connection-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Tracks the incoming connection and check the connection limit</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>onConnect(connection: Connection)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>connection</span> <code class='quiet'>(Connection)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='connectionmanagerondisconnect'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>onDisconnect(connection)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/index.js#L213-L225'>
|
|
<span>src/connection-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Removes the connection from tracking</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>onDisconnect(connection: Connection)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>connection</span> <code class='quiet'>(Connection)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='connectionmanagerget'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>get(peerId)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/index.js#L232-L238'>
|
|
<span>src/connection-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get a connection with a peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>get(peerId: PeerId): Connection</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>Connection</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='connectionmanagergetall'>
|
|
<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'>getAll(peerId)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/index.js#L245-L258'>
|
|
<span>src/connection-manager/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get all open connections with a peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getAll(peerId: PeerId): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Connection></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Connection></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='globalthis'>
|
|
globalThis
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/latency-monitor.js#L8-L8'>
|
|
<span>src/connection-manager/latency-monitor.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>This code is based on <code>latency-monitor</code> (<a href="https://github.com/mlucool/latency-monitor">https://github.com/mlucool/latency-monitor</a>) by <code>mlucool</code> (<a href="https://github.com/mlucool">https://github.com/mlucool</a>), available under Apache License 2.0 (<a href="https://github.com/mlucool/latency-monitor/blob/master/LICENSE">https://github.com/mlucool/latency-monitor/blob/master/LICENSE</a>)</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>globalThis</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='summaryobject'>
|
|
SummaryObject
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/latency-monitor.js#L13-L20'>
|
|
<span>src/connection-manager/latency-monitor.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>SummaryObject</div>
|
|
|
|
<p>
|
|
Type:
|
|
<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Properties</div>
|
|
<div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>events</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>)</code>
|
|
: How many events were called
|
|
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>minMS</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>)</code>
|
|
: What was the min time for a cb to be called
|
|
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>maxMS</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>)</code>
|
|
: What was the max time for a cb to be called
|
|
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>avgMs</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>)</code>
|
|
: What was the average time for a cb to be called
|
|
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>lengthMs</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>)</code>
|
|
: How long this interval was in ms
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='latencymonitor'>
|
|
LatencyMonitor
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/latency-monitor.js#L38-L240'>
|
|
<span>src/connection-manager/latency-monitor.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>A class to monitor latency of any async function which works in a browser or node. This works by periodically calling
|
|
the asyncTestFn and timing how long it takes the callback to be called. It can also periodically emit stats about this.
|
|
This can be disabled and stats can be pulled via setting dataEmitIntervalMs = 0.</p>
|
|
<p>The default implementation is an event loop latency monitor. This works by firing periodic events into the event loop
|
|
and timing how long it takes to get back.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new LatencyMonitor($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, latencyCheckIntervalMs: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>, dataEmitIntervalMs: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>, asyncTestFn: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">function</a>?, latencyRandomPercentage: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>)</div>
|
|
|
|
|
|
<p>
|
|
Extends
|
|
|
|
EventEmitter
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>
|
|
= <code>{}</code>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.latencyCheckIntervalMs</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.dataEmitIntervalMs</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.asyncTestFn</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.latencyRandomPercentage</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>latencyCheckIntervalMs</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>
|
|
= <code>500</code>)</code>
|
|
How often to add a latency check event (ms)
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>dataEmitIntervalMs</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>
|
|
= <code>5000</code>)</code>
|
|
How often to summarize latency check events. null or 0 disables event firing
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>asyncTestFn</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">function</a>?)</code>
|
|
What cb-style async function to use
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>latencyRandomPercentage</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>
|
|
= <code>5</code>)</code>
|
|
What percent (+/-) of latencyCheckIntervalMs should we randomly use? This helps avoid alignment to other events.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Example</div>
|
|
|
|
|
|
<pre class='p1 overflow-auto round fill-light'><span class="hljs-keyword">const</span> monitor = <span class="hljs-keyword">new</span> LatencyMonitor();
|
|
monitor.on(<span class="hljs-string">'data'</span>, (summary) => <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Event Loop Latency: %O'</span>, summary));</pre>
|
|
|
|
|
|
<pre class='p1 overflow-auto round fill-light'><span class="hljs-keyword">const</span> monitor = <span class="hljs-keyword">new</span> LatencyMonitor({<span class="hljs-attr">latencyCheckIntervalMs</span>: <span class="hljs-number">1000</span>, <span class="hljs-attr">dataEmitIntervalMs</span>: <span class="hljs-number">60000</span>, <span class="hljs-attr">asyncTestFn</span>:ping});
|
|
monitor.on(<span class="hljs-string">'data'</span>, (summary) => <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Ping Pong Latency: %O'</span>, summary));</pre>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='latencymonitorgetsummary'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>getSummary()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/latency-monitor.js#L157-L173'>
|
|
<span>src/connection-manager/latency-monitor.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Calling this function will end the collection period. If a timing event was already fired and somewhere in the queue,
|
|
it will not count for this time period</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getSummary(): <a href="#summaryobject">SummaryObject</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#summaryobject">SummaryObject</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id=''>
|
|
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/visibility-change-emitter.js#L6-L6'>
|
|
<span>src/connection-manager/visibility-change-emitter.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>This code is based on <code>latency-monitor</code> (<a href="https://github.com/mlucool/latency-monitor">https://github.com/mlucool/latency-monitor</a>) by <code>mlucool</code> (<a href="https://github.com/mlucool">https://github.com/mlucool</a>), available under Apache License 2.0 (<a href="https://github.com/mlucool/latency-monitor/blob/master/LICENSE">https://github.com/mlucool/latency-monitor/blob/master/LICENSE</a>)</p>
|
|
|
|
<div class='pre p1 fill-light mt0'></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='visibilitychangeemitter'>
|
|
VisibilityChangeEmitter
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/visibility-change-emitter.js#L35-L118'>
|
|
<span>src/connection-manager/visibility-change-emitter.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Listen to page visibility change events (i.e. when the page is focused / blurred) by an event emitter.</p>
|
|
<p>Warning: This does not work on all browsers, but should work on all modern browsers</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new VisibilityChangeEmitter()</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Example</div>
|
|
|
|
|
|
<pre class='p1 overflow-auto round fill-light'><span class="hljs-keyword">const</span> myVisibilityEmitter = <span class="hljs-keyword">new</span> VisibilityChangeEmitter();
|
|
|
|
myVisibilityEmitter.on(<span class="hljs-string">'visibilityChange'</span>, (pageInFocus) => {
|
|
<span class="hljs-keyword">if</span> ( pageInFocus ){
|
|
<span class="hljs-comment">// Page is in focus</span>
|
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'In focus'</span>);
|
|
}
|
|
<span class="hljs-keyword">else</span> {
|
|
<span class="hljs-comment">// Page is blurred</span>
|
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Out of focus'</span>);
|
|
}
|
|
});
|
|
<span class="hljs-comment">// To access the visibility state directly, call:</span>
|
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Am I focused now? '</span> + myVisibilityEmitter.isVisible());</pre>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='isvisible'>
|
|
isVisible
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/connection-manager/visibility-change-emitter.js#L97-L103'>
|
|
<span>src/connection-manager/visibility-change-emitter.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>The function returns <code>true</code> if the page is visible or <code>false</code> if the page is not visible and
|
|
<code>undefined</code> if the page visibility API is not supported by the browser.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>isVisible(): (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a> | void)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a> | void)</code>:
|
|
whether the page is now visible or not (undefined is unknown)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='constructor'>
|
|
constructor
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/index.js#L29-L38'>
|
|
<span>src/circuit/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Creates an instance of Circuit.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new constructor(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.libp2p</span> <code class='quiet'><a href="#libp2p">Libp2p</a></code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.upgrader</span> <code class='quiet'><a href="#upgrader">Upgrader</a></code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='dial'>
|
|
dial
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/index.js#L102-L148'>
|
|
<span>src/circuit/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Dial a peer over a relay</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>dial(ma: multiaddr, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>): Connection</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>ma</span> <code class='quiet'>(multiaddr)</code>
|
|
the multiaddr of the peer to dial
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
dial options
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.signal</span> <code class='quiet'>AbortSignal?</code>
|
|
</td>
|
|
<td class='break-word'><span>An optional abort signal
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>Connection</code>:
|
|
the connection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='createlistener'>
|
|
createListener
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/index.js#L157-L167'>
|
|
<span>src/circuit/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Create a listener</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>createListener(options: any, handler: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">Function</a>): <a href="#listener">listener</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(any)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>handler</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">Function</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#listener">listener</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='filter'>
|
|
filter
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/index.js#L175-L181'>
|
|
<span>src/circuit/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Filter check for all Multiaddrs that this transport can dial on</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>filter(multiaddrs: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr>): <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'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='index'>
|
|
index
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/index.js#L187-L187'>
|
|
<span>src/circuit/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>index</div>
|
|
|
|
<p>
|
|
Type:
|
|
Circuit
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Static Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='indexmulticodecs'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>multicodecs</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/identify/index.js#L345-L348'>
|
|
<span>src/identify/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>The protocols the IdentifyService supports</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>multicodecs</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='listener'>
|
|
listener
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/listener.js#L14-L66'>
|
|
<span>src/circuit/listener.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>listener(circuit: any): Listener</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>circuit</span> <code class='quiet'>(any)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>Listener</code>:
|
|
a transport listener
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Static Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='listenerlisten'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>listen(addr)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/listener.js#L24-L32'>
|
|
<span>src/circuit/listener.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Add swarm handler and listen for incoming connections</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>listen(addr: Multiaddr): void</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>addr</span> <code class='quiet'>(Multiaddr)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>void</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='listenerclose'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>close()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/listener.js#L39-L39'>
|
|
<span>src/circuit/listener.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>TODO: Remove the peers from our topology</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>close(): void</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>void</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='listenergetaddrs'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>getAddrs()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/listener.js#L57-L63'>
|
|
<span>src/circuit/listener.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get fixed up multiaddrs</p>
|
|
<p>NOTE: This method will grab the peers multiaddrs and expand them such that:</p>
|
|
<p>a) If it's an existing /p2p-circuit address for a specific relay i.e.
|
|
<code>/ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit</code> this method will expand the
|
|
address to <code>/ip4/0.0.0.0/tcp/0/ipfs/QmRelay/p2p-circuit/ipfs/QmPeer</code> where
|
|
<code>QmPeer</code> is this peers id
|
|
b) If it's not a /p2p-circuit address, it will encapsulate the address as a /p2p-circuit
|
|
addr, such when dialing over a relay with this address, it will create the circuit using
|
|
the encapsulated transport address. This is useful when for example, a peer should only
|
|
be dialed over TCP rather than any other transport</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getAddrs(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='hop'>
|
|
hop
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/circuit/hop.js#L98-L118'>
|
|
<span>src/circuit/circuit/hop.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Performs a HOP request to a relay peer, to request a connection to another
|
|
peer. A new, virtual, connection will be created between the two via the relay.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>hop(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.connection</span> <code class='quiet'>Connection</code>
|
|
</td>
|
|
<td class='break-word'><span>Connection to the relay
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.request</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.circuit</span> <code class='quiet'>Circuit</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='writeresponse'>
|
|
writeResponse
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/circuit/utils.js#L12-L17'>
|
|
<span>src/circuit/circuit/utils.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Write a response</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>writeResponse(streamHandler: StreamHandler, status: CircuitRelay.Status)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>streamHandler</span> <code class='quiet'>(StreamHandler)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>status</span> <code class='quiet'>(CircuitRelay.Status)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='validateaddrs'>
|
|
validateAddrs
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/circuit/utils.js#L25-L47'>
|
|
<span>src/circuit/circuit/utils.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Validate incomming HOP/STOP message</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>validateAddrs(msg: any, streamHandler: StreamHandler)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>msg</span> <code class='quiet'>(any)</code>
|
|
A CircuitRelay unencoded protobuf message
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>streamHandler</span> <code class='quiet'>(StreamHandler)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='constructor'>
|
|
constructor
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/circuit/stream-handler.js#L19-L24'>
|
|
<span>src/circuit/circuit/stream-handler.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Create a stream handler for connection</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>constructor(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.stream</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span>A duplex iterable
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.maxLength</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
|
|
|
|
(default <code>4096</code>)
|
|
</td>
|
|
<td class='break-word'><span>max bytes length of message
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='read'>
|
|
read
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/circuit/stream-handler.js#L31-L42'>
|
|
<span>src/circuit/circuit/stream-handler.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Read and decode message</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>read(): void</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>void</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='write'>
|
|
write
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/circuit/stream-handler.js#L49-L52'>
|
|
<span>src/circuit/circuit/stream-handler.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Encode and write array of buffers</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>write(msg: any)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>msg</span> <code class='quiet'>(any)</code>
|
|
An unencoded CircuitRelay protobuf message
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='rest'>
|
|
rest
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/circuit/stream-handler.js#L59-L62'>
|
|
<span>src/circuit/circuit/stream-handler.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Return the handshake rest stream and invalidate handler</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>rest(): any</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>any</code>:
|
|
A duplex iterable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='close'>
|
|
close
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/circuit/circuit/stream-handler.js#L74-L77'>
|
|
<span>src/circuit/circuit/stream-handler.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Close the stream</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>close(): void</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>void</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='constructor'>
|
|
constructor
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/dialer/index.js#L30-L44'>
|
|
<span>src/dialer/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>new constructor($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>, peerStore: Peerstore)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.transportManager</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.peerStore</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.concurrency</span> <code class='quiet'>any</code>
|
|
|
|
(default <code>MAX_PARALLEL_DIALS</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.timeout</span> <code class='quiet'>any</code>
|
|
|
|
(default <code>DIAL_TIMEOUT</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.perPeerLimit</span> <code class='quiet'>any</code>
|
|
|
|
(default <code>MAX_PER_PEER_DIALS</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.transportManager</span> <code class='quiet'>TransportManager</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.concurrency</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code>
|
|
</td>
|
|
<td class='break-word'><span>Number of max concurrent dials. Defaults to
|
|
<code>MAX_PARALLEL_DIALS</code>
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.timeout</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code>
|
|
</td>
|
|
<td class='break-word'><span>How long a dial attempt is allowed to take. Defaults to
|
|
<code>DIAL_TIMEOUT</code>
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerStore</span> <code class='quiet'>(Peerstore)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='destroy'>
|
|
destroy
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/dialer/index.js#L49-L58'>
|
|
<span>src/dialer/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Clears any pending dials</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>destroy()</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='connecttopeer'>
|
|
connectToPeer
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/dialer/index.js#L70-L92'>
|
|
<span>src/dialer/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Connects to a given <code>peer</code> by dialing all of its known addresses.
|
|
The dial to the first address that is successfully able to upgrade a connection
|
|
will be used.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>connectToPeer(peer: (PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>), options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peer</span> <code class='quiet'>((PeerId | Multiaddr | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>))</code>
|
|
The peer to dial
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?
|
|
= <code>{}</code>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.signal</span> <code class='quiet'>AbortSignal?</code>
|
|
</td>
|
|
<td class='break-word'><span>An AbortController signal
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='_createdialtarget'>
|
|
_createDialTarget
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/dialer/index.js#L108-L128'>
|
|
<span>src/dialer/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>_createDialTarget(peer: any)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peer</span> <code class='quiet'>(any)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Properties</div>
|
|
<div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>id</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>addrs</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr>)</code>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='_creatependingdial'>
|
|
_createPendingDial
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/dialer/index.js#L146-L175'>
|
|
<span>src/dialer/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>_createPendingDial(dialTarget: any, options: any)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>dialTarget</span> <code class='quiet'>(any)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(any)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Properties</div>
|
|
<div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>dialRequest</span> <code class='quiet'>(DialRequest)</code>
|
|
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>controller</span> <code class='quiet'>(TimeoutController)</code>
|
|
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>promise</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>)</code>
|
|
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>destroy</span> <code class='quiet'>(function (): void)</code>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='constructor'>
|
|
constructor
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/dialer/dial-request.js#L24-L32'>
|
|
<span>src/dialer/dial-request.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Manages running the <code>dialAction</code> on multiple provided <code>addrs</code> in parallel
|
|
up to a maximum determined by the number of tokens returned
|
|
from <code>dialer.getTokens</code>. Once a DialRequest is created, it can be
|
|
started using <code>DialRequest.run(options)</code>. Once a single dial has succeeded,
|
|
all other dials in the request will be cancelled.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>constructor(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.addrs</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr></code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.dialAction</span> <code class='quiet'>function (Multiaddr): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.dialer</span> <code class='quiet'>Dialer</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='run'>
|
|
run
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/dialer/dial-request.js#L40-L77'>
|
|
<span>src/dialer/dial-request.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>run(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>): Connection</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.signal</span> <code class='quiet'>AbortSignal</code>
|
|
</td>
|
|
<td class='break-word'><span>An AbortController signal
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>Connection</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='keyinfo'>
|
|
KeyInfo
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/index.js#L82-L89'>
|
|
<span>src/keychain/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Information about a key.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>KeyInfo</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'>id</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
: The universally unique key id.
|
|
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>name</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
: The local key name.
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='keychain'>
|
|
Keychain
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/index.js#L99-L467'>
|
|
<span>src/keychain/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Manages the lifecycle of a key. Keys are encrypted at rest using PKCS #8.</p>
|
|
<p>A key in the store has two entries</p>
|
|
<ul>
|
|
<li>'/info/<em>key-name</em>', contains the KeyInfo for the key</li>
|
|
<li>'/pkcs8/<em>key-name</em>', contains the PKCS #8 for the key</li>
|
|
</ul>
|
|
|
|
<div class='pre p1 fill-light mt0'>new Keychain(store: DS, 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'>store</span> <code class='quiet'>(DS)</code>
|
|
where the key are.
|
|
|
|
</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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Static Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='keychaingenerateoptions'>
|
|
<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'>generateOptions()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/index.js#L157-L162'>
|
|
<span>src/keychain/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Generates the options for a keychain. A random salt is produced.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>generateOptions(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='keychainoptions'>
|
|
<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'>options</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/index.js#L170-L172'>
|
|
<span>src/keychain/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Gets an object that can encrypt/decrypt protected data.
|
|
The default options for a keychain.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>options</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='keychaincms'>
|
|
<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'>cms</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/index.js#L148-L150'>
|
|
<span>src/keychain/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Gets an object that can encrypt/decrypt protected data
|
|
using the Cryptographic Message Syntax (CMS).</p>
|
|
<p>CMS describes an encapsulation syntax for data protection. It
|
|
is used to digitally sign, digest, authenticate, or encrypt
|
|
arbitrary message content.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>cms</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#cms">CMS</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='keychaincreatekey'>
|
|
<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'>createKey(name, type, size?)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/index.js#L182-L226'>
|
|
<span>src/keychain/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Create a new key.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>createKey(name: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, type: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, size: int?): <a href="#keyinfo">KeyInfo</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>name</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
The local key name; cannot already exist.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<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>
|
|
One of the key types; 'rsa'.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>size</span> <code class='quiet'>(int?)</code>
|
|
The key size in bits. Used for rsa keys only.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#keyinfo">KeyInfo</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='keychainlistkeys'>
|
|
<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'>listKeys()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/index.js#L233-L245'>
|
|
<span>src/keychain/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>List all the keys.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>listKeys(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<a href="#keyinfo">KeyInfo</a>></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<a href="#keyinfo">KeyInfo</a>></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='keychainfindkeybyid'>
|
|
<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'>findKeyById(id)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/index.js#L253-L260'>
|
|
<span>src/keychain/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Find a key by it's id.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>findKeyById(id: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="#keyinfo">KeyInfo</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>id</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
The universally unique key identifier.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#keyinfo">KeyInfo</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='keychainfindkeybyname'>
|
|
<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'>findKeyByName(name)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/index.js#L268-L280'>
|
|
<span>src/keychain/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Find a key by it's name.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>findKeyByName(name: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="#keyinfo">KeyInfo</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>name</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
The local key name.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#keyinfo">KeyInfo</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='keychainremovekey'>
|
|
<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'>removeKey(name)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/index.js#L288-L300'>
|
|
<span>src/keychain/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Remove an existing key.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>removeKey(name: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="#keyinfo">KeyInfo</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>name</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
The local key name; must already exist.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#keyinfo">KeyInfo</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='keychainrenamekey'>
|
|
<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'>renameKey(oldName, newName)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/index.js#L309-L341'>
|
|
<span>src/keychain/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Rename a key</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>renameKey(oldName: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, newName: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="#keyinfo">KeyInfo</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>oldName</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
The old local key name; must already exist.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>newName</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
The new local key name; must not already exist.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#keyinfo">KeyInfo</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='keychainexportkey'>
|
|
<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'>exportKey(name, password)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/index.js#L350-L367'>
|
|
<span>src/keychain/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Export an existing key as a PEM encrypted PKCS #8 string</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>exportKey(name: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, password: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>name</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
The local key name; must already exist.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>password</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
The password
|
|
|
|
</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>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='keychainimportkey'>
|
|
<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'>importKey(name, pem, password)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/index.js#L377-L414'>
|
|
<span>src/keychain/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Import a new key from a PEM encoded PKCS #8 string</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>importKey(name: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, pem: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, password: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="#keyinfo">KeyInfo</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>name</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
The local key name; must not already exist.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>pem</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
The PEM encoded PKCS #8 string
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>password</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
The password.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#keyinfo">KeyInfo</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='cms'>
|
|
CMS
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/cms.js#L20-L122'>
|
|
<span>src/keychain/cms.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Cryptographic Message Syntax (aka PKCS #7)</p>
|
|
<p>CMS describes an encapsulation syntax for data protection. It
|
|
is used to digitally sign, digest, authenticate, or encrypt
|
|
arbitrary message content.</p>
|
|
<p>See RFC 5652 for all the details.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new CMS(keychain: <a href="#keychain">Keychain</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>keychain</span> <code class='quiet'>(<a href="#keychain">Keychain</a>)</code>
|
|
the available keys
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='cmsencrypt'>
|
|
<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'>encrypt(name, plain)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/cms.js#L43-L62'>
|
|
<span>src/keychain/cms.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Creates some protected data.</p>
|
|
<p>The output Uint8Array contains the PKCS #7 message in DER.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>encrypt(name: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, plain: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</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'>name</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
The local key name.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>plain</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>)</code>
|
|
The data to encrypt.
|
|
|
|
</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>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='cmsdecrypt'>
|
|
<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'>decrypt(cmsData)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/cms.js#L73-L121'>
|
|
<span>src/keychain/cms.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Reads some protected data.</p>
|
|
<p>The keychain must contain one of the keys used to encrypt the data. If none of the keys
|
|
exists, an Error is returned with the property 'missingKeys'. It is array of key ids.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>decrypt(cmsData: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</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'>cmsData</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>)</code>
|
|
The CMS encrypted data to decrypt.
|
|
|
|
</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>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='certificateforkey'>
|
|
certificateForKey
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/util.js#L19-L70'>
|
|
<span>src/keychain/util.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Gets a self-signed X.509 certificate for the key.</p>
|
|
<p>The output Uint8Array contains the PKCS #7 message in DER.</p>
|
|
<p>TODO: move to libp2p-crypto package</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>certificateForKey(key: <a href="#keyinfo">KeyInfo</a>, privateKey: RsaPrivateKey): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>key</span> <code class='quiet'>(<a href="#keyinfo">KeyInfo</a>)</code>
|
|
The id and name of the key
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>privateKey</span> <code class='quiet'>(RsaPrivateKey)</code>
|
|
The naked key
|
|
|
|
</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/Uint8Array">Uint8Array</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='findasync'>
|
|
findAsync
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/keychain/util.js#L82-L87'>
|
|
<span>src/keychain/util.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Finds the first item in a collection that is matched in the
|
|
<code>asyncCompare</code> function.</p>
|
|
<p><code>asyncCompare</code> is an async function that must
|
|
resolve to either <code>true</code> or <code>false</code>.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>findAsync(array: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>, asyncCompare: function (any))</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>array</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>asyncCompare</span> <code class='quiet'>(function (any))</code>
|
|
An async function that returns a boolean
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='constructor'>
|
|
constructor
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/index.js#L30-L42'>
|
|
<span>src/metrics/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>constructor(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.connectionManager</span> <code class='quiet'><a href="#connectionmanager">ConnectionManager</a></code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.computeThrottleMaxQueueSize</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.computeThrottleTimeout</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.movingAverageIntervals</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>></code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.maxOldPeersRetention</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='start'>
|
|
start
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/index.js#L48-L50'>
|
|
<span>src/metrics/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Must be called for stats to saved. Any data pushed for tracking
|
|
will be ignored.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>start()</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='stop'>
|
|
stop
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/index.js#L56-L65'>
|
|
<span>src/metrics/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Stops all averages timers and prevents new data from being tracked.
|
|
Once <code>stop</code> is called, <code>start</code> must be called to resume stats tracking.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>stop()</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='global'>
|
|
global
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/index.js#L71-L73'>
|
|
<span>src/metrics/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Gets the global <code>Stats</code> object</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>global</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#stats">Stats</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='peers'>
|
|
peers
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/index.js#L79-L81'>
|
|
<span>src/metrics/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Returns a list of <code>PeerId</code> strings currently being tracked</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>peers</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='forpeer'>
|
|
forPeer
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/index.js#L89-L92'>
|
|
<span>src/metrics/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Returns the <code>Stats</code> object for the given <code>PeerId</code> whether it
|
|
is a live peer, or in the disconnected peer LRU cache.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>forPeer(peerId: PeerId): <a href="#stats">Stats</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#stats">Stats</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='protocols'>
|
|
protocols
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/index.js#L98-L100'>
|
|
<span>src/metrics/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Returns a list of all protocol strings currently being tracked.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>protocols</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='forprotocol'>
|
|
forProtocol
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/index.js#L107-L109'>
|
|
<span>src/metrics/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Returns the <code>Stats</code> object for the given <code>protocol</code>.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>forProtocol(protocol: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="#stats">Stats</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>protocol</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#stats">Stats</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='onpeerdisconnected'>
|
|
onPeerDisconnected
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/index.js#L117-L125'>
|
|
<span>src/metrics/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Should be called when all connections to a given peer
|
|
have closed. The <code>Stats</code> collection for the peer will
|
|
be stopped and moved to an LRU for temporary retention.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>onPeerDisconnected(peerId: PeerId)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='updateplaceholder'>
|
|
updatePlaceholder
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/index.js#L173-L191'>
|
|
<span>src/metrics/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Replaces the <code>PeerId</code> string with the given <code>peerId</code>.
|
|
If stats are already being tracked for the given <code>peerId</code>, the
|
|
placeholder stats will be merged with the existing stats.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>updatePlaceholder(placeholder: PeerId, peerId: PeerId)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>placeholder</span> <code class='quiet'>(PeerId)</code>
|
|
A peerId string
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='trackstream'>
|
|
trackStream
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/index.js#L206-L231'>
|
|
<span>src/metrics/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Tracks data running through a given Duplex Iterable <code>stream</code>. If
|
|
the <code>peerId</code> is not provided, a placeholder string will be created and
|
|
returned. This allows lazy tracking of a peer when the peer is not yet known.
|
|
When the <code>PeerId</code> is known, <code>Metrics.updatePlaceholder</code> should be called
|
|
with the placeholder string returned from here, and the known <code>PeerId</code>.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>trackStream(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.stream</span> <code class='quiet'>{sink: function (any), source: function ()}</code>
|
|
</td>
|
|
<td class='break-word'><span>A duplex iterable stream
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.protocol</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>?</code>
|
|
</td>
|
|
<td class='break-word'><span>The protocol the stream is running
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.peerId</span> <code class='quiet'>PeerId?</code>
|
|
</td>
|
|
<td class='break-word'><span>The id of the remote peer that's connected
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.remotePeer</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code>:
|
|
The peerId string or placeholder string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='mergestats'>
|
|
mergeStats
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/index.js#L240-L249'>
|
|
<span>src/metrics/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Merges <code>other</code> into <code>target</code>. <code>target</code> will be modified
|
|
and returned.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>mergeStats(target: <a href="#stats">Stats</a>, other: <a href="#stats">Stats</a>): <a href="#stats">Stats</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>target</span> <code class='quiet'>(<a href="#stats">Stats</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>other</span> <code class='quiet'>(<a href="#stats">Stats</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#stats">Stats</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='old-peers'>
|
|
old-peers
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/old-peers.js#L11-L15'>
|
|
<span>src/metrics/old-peers.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Creates and returns a Least Recently Used Cache</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>old-peers(maxSize: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>): LRUCache</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>maxSize</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>LRUCache</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='stats'>
|
|
Stats
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/stats.js#L14-L258'>
|
|
<span>src/metrics/stats.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>A queue based manager for stat processing</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new Stats(initialCounters: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><<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'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/stats.js#L49-L53'>
|
|
<span>src/metrics/stats.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Initializes the internal timer if there are items in the queue. This
|
|
should only need to be called if <code>Stats.stop</code> was previously called, as
|
|
<code>Stats.push</code> will also start the processing.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>start(): void</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>void</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='statsstop'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>stop()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/stats.js#L61-L66'>
|
|
<span>src/metrics/stats.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Stops processing and computing of stats by clearing the internal
|
|
timer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>stop(): void</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>void</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='statssnapshot'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>snapshot</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/stats.js#L73-L75'>
|
|
<span>src/metrics/stats.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Returns a clone of the current stats.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>snapshot</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map">Map</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, Stat></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='statsmovingaverages'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>movingAverages</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/stats.js#L82-L84'>
|
|
<span>src/metrics/stats.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Returns a clone of the internal movingAverages</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>movingAverages</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><MovingAverage></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='statstojson'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>toJSON()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/stats.js#L91-L109'>
|
|
<span>src/metrics/stats.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Returns a plain JSON object of the stats</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>toJSON(): any</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>any</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='statspush'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>push(counter, inc)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/metrics/stats.js#L119-L122'>
|
|
<span>src/metrics/stats.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Pushes the given operation data to the queue, along with the
|
|
current Timestamp, then resets the update timer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>push(counter: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, inc: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>): void</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>counter</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>inc</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>void</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='constructor'>
|
|
constructor
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/transport-manager.js#L18-L24'>
|
|
<span>src/transport-manager.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>new constructor(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.libp2p</span> <code class='quiet'><a href="#libp2p">Libp2p</a></code>
|
|
</td>
|
|
<td class='break-word'><span>The Libp2p instance. It will be passed to the transports.
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.upgrader</span> <code class='quiet'><a href="#upgrader">Upgrader</a></code>
|
|
</td>
|
|
<td class='break-word'><span>The upgrader to provide to the transports
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.faultTolerance</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code>
|
|
|
|
(default <code>FAULT_TOLERANCE.FATAL_ALL</code>)
|
|
</td>
|
|
<td class='break-word'><span>Address listen error tolerance.
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='add'>
|
|
add
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/transport-manager.js#L34-L53'>
|
|
<span>src/transport-manager.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Adds a <code>Transport</code> to the manager</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>add(key: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, Transport: Transport, transportOptions: any): void</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>key</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>Transport</span> <code class='quiet'>(Transport)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>transportOptions</span> <code class='quiet'>(any
|
|
= <code>{}</code>)</code>
|
|
Additional options to pass to the transport
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>void</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='close'>
|
|
close
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/transport-manager.js#L59-L74'>
|
|
<span>src/transport-manager.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Stops all listeners</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>close()</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='dial'>
|
|
dial
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/transport-manager.js#L82-L94'>
|
|
<span>src/transport-manager.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Dials the given Multiaddr over it's supported transport</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>dial(ma: Multiaddr, options: any): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>ma</span> <code class='quiet'>(Multiaddr)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(any)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='getaddrs'>
|
|
getAddrs
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/transport-manager.js#L100-L108'>
|
|
<span>src/transport-manager.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Returns all Multiaddr's the listeners are using</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getAddrs(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='gettransports'>
|
|
getTransports
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/transport-manager.js#L114-L116'>
|
|
<span>src/transport-manager.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Returns all the transports instances.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getTransports(): Iterator<Transport></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>Iterator<Transport></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='transportformultiaddr'>
|
|
transportForMultiaddr
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/transport-manager.js#L123-L129'>
|
|
<span>src/transport-manager.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Finds a transport that matches the given Multiaddr</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>transportForMultiaddr(ma: Multiaddr): (Transport | null)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>ma</span> <code class='quiet'>(Multiaddr)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>(Transport | null)</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='listen'>
|
|
listen
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/transport-manager.js#L135-L184'>
|
|
<span>src/transport-manager.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Starts listeners for each listen Multiaddr.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>listen()</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='remove'>
|
|
remove
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/transport-manager.js#L193-L204'>
|
|
<span>src/transport-manager.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Removes the given transport from the manager.
|
|
If a transport has any running listeners, they will be closed.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>remove(key: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>key</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='removeall'>
|
|
removeAll
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/transport-manager.js#L211-L218'>
|
|
<span>src/transport-manager.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Removes all transports from the manager.
|
|
If any listeners are running, they will be closed.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>removeAll()</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='fault_tolerance'>
|
|
FAULT_TOLERANCE
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/transport-manager.js#L228-L231'>
|
|
<span>src/transport-manager.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Enum Transport Manager Fault Tolerance values.
|
|
FATAL_ALL should be used for failing in any listen circumstance.
|
|
NO_FATAL should be used for not failing when not listening.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>FAULT_TOLERANCE</div>
|
|
|
|
<p>
|
|
Type:
|
|
<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='upgrader'>
|
|
Upgrader
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/upgrader.js#L30-L418'>
|
|
<span>src/upgrader.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>new Upgrader($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.localPeer</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.metrics</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.cryptos</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.muxers</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.onConnectionEnd</span> <code class='quiet'>any</code>
|
|
|
|
(default <code>()=>{}</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.onConnection</span> <code class='quiet'>any</code>
|
|
|
|
(default <code>()=>{}</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Properties</div>
|
|
<div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>sink</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">function</a>)</code>
|
|
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>source</span> <code class='quiet'>(AsyncIterator)</code>
|
|
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>conn</span> <code class='quiet'>(any)</code>
|
|
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>remoteAddr</span> <code class='quiet'>(Multiaddr)</code>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='upgraderupgradeinbound'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>upgradeInbound(maConn)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/upgrader.js#L64-L123'>
|
|
<span>src/upgrader.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Upgrades an inbound connection</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>upgradeInbound(maConn: MultiaddrConnection): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>maConn</span> <code class='quiet'>(MultiaddrConnection)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='upgraderupgradeoutbound'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>upgradeOutbound(maConn)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/upgrader.js#L131-L197'>
|
|
<span>src/upgrader.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Upgrades an outbound connection</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>upgradeOutbound(maConn: MultiaddrConnection): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>maConn</span> <code class='quiet'>(MultiaddrConnection)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='upgrader'>
|
|
Upgrader
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/upgrader.js#L30-L418'>
|
|
<span>src/upgrader.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>new Upgrader($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.localPeer</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.metrics</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.cryptos</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.muxers</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.onConnectionEnd</span> <code class='quiet'>any</code>
|
|
|
|
(default <code>()=>{}</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.onConnection</span> <code class='quiet'>any</code>
|
|
|
|
(default <code>()=>{}</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Properties</div>
|
|
<div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>conn</span> <code class='quiet'>(any)</code>
|
|
: A duplex iterable
|
|
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>remotePeer</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<span class='code bold'>protocol</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='upgraderupgradeinbound'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>upgradeInbound(maConn)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/upgrader.js#L64-L123'>
|
|
<span>src/upgrader.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Upgrades an inbound connection</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>upgradeInbound(maConn: MultiaddrConnection): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>maConn</span> <code class='quiet'>(MultiaddrConnection)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='upgraderupgradeoutbound'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>upgradeOutbound(maConn)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/upgrader.js#L131-L197'>
|
|
<span>src/upgrader.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Upgrades an outbound connection</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>upgradeOutbound(maConn: MultiaddrConnection): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>maConn</span> <code class='quiet'>(MultiaddrConnection)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><Connection></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='peerstore'>
|
|
PeerStore
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/index.js#L28-L139'>
|
|
<span>src/peer-store/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Responsible for managing known peers, as well as their addresses, protocols and metadata.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new PeerStore($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</div>
|
|
|
|
|
|
<p>
|
|
Extends
|
|
|
|
EventEmitter
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.peerId</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'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='peerstoreaddressbook'>
|
|
<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'>addressBook</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/index.js#L48-L48'>
|
|
<span>src/peer-store/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>AddressBook containing a map of peerIdStr to Address.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>addressBook</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='peerstorekeybook'>
|
|
<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'>keyBook</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/index.js#L53-L53'>
|
|
<span>src/peer-store/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>KeyBook containing a map of peerIdStr to their PeerId with public keys.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>keyBook</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='peerstoremetadatabook'>
|
|
<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'>metadataBook</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/index.js#L58-L58'>
|
|
<span>src/peer-store/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>MetadataBook containing a map of peerIdStr to their metadata Map.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>metadataBook</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='peerstoreprotobook'>
|
|
<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'>protoBook</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/index.js#L63-L63'>
|
|
<span>src/peer-store/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>ProtoBook containing a map of peerIdStr to supported protocols.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>protoBook</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='peerstorestart'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>start()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/index.js#L69-L69'>
|
|
<span>src/peer-store/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Start the PeerStore.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>start()</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='peerstorestop'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>stop()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/index.js#L74-L74'>
|
|
<span>src/peer-store/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Stop the PeerStore.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>stop()</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='peerstorepeers'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>peers</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/index.js#L80-L97'>
|
|
<span>src/peer-store/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get all the stored information of every peer known.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>peers</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map">Map</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, Peer></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='peerstoredelete'>
|
|
<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'>delete(peerId)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/index.js#L104-L111'>
|
|
<span>src/peer-store/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Delete the information of the given peer in every book.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>delete(peerId: PeerId): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</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>:
|
|
true if found and removed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='peerstoreget'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>get(peerId)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/index.js#L118-L138'>
|
|
<span>src/peer-store/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get the stored information of a given peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>get(peerId: PeerId): Peer</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>Peer</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='addressbook'>
|
|
AddressBook
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/address-book.js#L23-L332'>
|
|
<span>src/peer-store/address-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>The AddressBook is responsible for keeping the known multiaddrs
|
|
of a peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new AddressBook(peerStore: <a href="#peerstore">PeerStore</a>)</div>
|
|
|
|
|
|
<p>
|
|
Extends
|
|
|
|
<a href="#book">Book</a>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerStore</span> <code class='quiet'>(<a href="#peerstore">PeerStore</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='addressbookdata'>
|
|
<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'>data</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/address-book.js#L71-L71'>
|
|
<span>src/peer-store/address-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Map known peers to their known Address Entries.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>data</div>
|
|
|
|
<p>
|
|
Type:
|
|
<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>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Entry>>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='addressbookconsumepeerrecord'>
|
|
<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'>consumePeerRecord(envelope)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/address-book.js#L81-L125'>
|
|
<span>src/peer-store/address-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>ConsumePeerRecord adds addresses from a signed peer record contained in a record envelope.
|
|
This will return a boolean that indicates if the record was successfully processed and added
|
|
into the AddressBook.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>consumePeerRecord(envelope: <a href="#envelope">Envelope</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>envelope</span> <code class='quiet'>(<a href="#envelope">Envelope</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/Boolean">boolean</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='addressbookgetrawenvelope'>
|
|
<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'>getRawEnvelope(peerId)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/address-book.js#L133-L141'>
|
|
<span>src/peer-store/address-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get the raw Envelope for a peer. Returns
|
|
undefined if no Envelope is found.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getRawEnvelope(peerId: PeerId): (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</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'>peerId</span> <code class='quiet'>(PeerId)</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/Uint8Array">Uint8Array</a> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined">undefined</a>)</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='addressbookgetpeerrecord'>
|
|
<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'>getPeerRecord(peerId)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/address-book.js#L149-L157'>
|
|
<span>src/peer-store/address-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get an Envelope containing a PeerRecord for the given peer.
|
|
Returns undefined if no record exists.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getPeerRecord(peerId: PeerId): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><(<a href="#envelope">Envelope</a> | void)></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><(<a href="#envelope">Envelope</a> | void)></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='addressbookset'>
|
|
<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'>set(peerId, multiaddrs)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/address-book.js#L169-L209'>
|
|
<span>src/peer-store/address-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Set known multiaddrs of a provided peer.
|
|
This will replace previously stored multiaddrs, if available.
|
|
Replacing stored multiaddrs might result in losing obtained certified addresses.
|
|
If you are not sure, it's recommended to use <code>add</code> instead.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>set(peerId: PeerId, multiaddrs: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr>): <a href="#addressbook">AddressBook</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#addressbook">AddressBook</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='addressbookadd'>
|
|
<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(peerId, multiaddrs)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/address-book.js#L218-L257'>
|
|
<span>src/peer-store/address-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Add known addresses of a provided peer.
|
|
If the peer is not known, it is set with the given addresses.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>add(peerId: PeerId, multiaddrs: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr>): <a href="#addressbook">AddressBook</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#addressbook">AddressBook</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='addressbookget'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>get(peerId)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/address-book.js#L265-L273'>
|
|
<span>src/peer-store/address-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get the known data of a provided peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>get(peerId: PeerId): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><data></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><data></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='addressbookgetmultiaddrsforpeer'>
|
|
<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'>getMultiaddrsForPeer(peerId)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/address-book.js#L312-L331'>
|
|
<span>src/peer-store/address-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get the known multiaddrs for a given peer. All returned multiaddrs
|
|
will include the encapsulated <code>PeerId</code> of the peer.
|
|
Returns <code>undefined</code> if there are no known multiaddrs for the given peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getMultiaddrsForPeer(peerId: PeerId): (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Multiaddr> | <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'>peerId</span> <code class='quiet'>(PeerId)</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> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined">undefined</a>)</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='eventtransformer'>
|
|
eventTransformer
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/address-book.js#L55-L65'>
|
|
<span>src/peer-store/address-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>PeerStore Event emitter, used by the AddressBook to emit:
|
|
"peer" - emitted when a peer is discovered by the node.
|
|
"change:multiaddrs" - emitted when the known multiaddrs of a peer change.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>eventTransformer</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='eventtransformer'>
|
|
eventTransformer
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/proto-book.js#L31-L36'>
|
|
<span>src/peer-store/proto-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>PeerStore Event emitter, used by the ProtoBook to emit:
|
|
"change:protocols" - emitted when the known protocols of a peer change.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>eventTransformer</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='book'>
|
|
Book
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/book.js#L15-L112'>
|
|
<span>src/peer-store/book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>The Book is the skeleton for the PeerStore books.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new Book($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, properties: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.peerStore</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.eventName</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.eventProperty</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.eventTransformer</span> <code class='quiet'>any</code>
|
|
|
|
(default <code>passthrough</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>properties</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='bookdata'>
|
|
<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'>data</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/book.js#L34-L34'>
|
|
<span>src/peer-store/book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Map known peers to their data.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>data</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='bookset'>
|
|
<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'>set(peerId, data)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/book.js#L42-L44'>
|
|
<span>src/peer-store/book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Set known data of a provided peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>set(peerId: PeerId, data: (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Data> | Data))</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>data</span> <code class='quiet'>((<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Data> | Data))</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='bookget'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>get(peerId)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/book.js#L84-L92'>
|
|
<span>src/peer-store/book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get the known data of a provided peer.
|
|
Returns <code>undefined</code> if there is no available data for the given peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>get(peerId: PeerId): (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Data> | <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'>peerId</span> <code class='quiet'>(PeerId)</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><Data> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined">undefined</a>)</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='bookdelete'>
|
|
<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'>delete(peerId)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/book.js#L99-L111'>
|
|
<span>src/peer-store/book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Deletes the provided peer from the book.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>delete(peerId: PeerId): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</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>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='keybook'>
|
|
KeyBook
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/key-book.js#L19-L83'>
|
|
<span>src/peer-store/key-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>The KeyBook is responsible for keeping the known public keys of a peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new KeyBook(peerStore: <a href="#peerstore">PeerStore</a>)</div>
|
|
|
|
|
|
<p>
|
|
Extends
|
|
|
|
<a href="#book">Book</a>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerStore</span> <code class='quiet'>(<a href="#peerstore">PeerStore</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='keybookdata'>
|
|
<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'>data</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/key-book.js#L36-L36'>
|
|
<span>src/peer-store/key-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Map known peers to their known Public Key.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>data</div>
|
|
|
|
<p>
|
|
Type:
|
|
<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>, PeerId>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='keybookset'>
|
|
<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'>set(peerId, publicKey)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/key-book.js#L46-L66'>
|
|
<span>src/peer-store/key-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Set the Peer public key.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>set(peerId: PeerId, publicKey: (RsaPublicKey | Ed25519PublicKey | Secp256k1PublicKey)): <a href="#keybook">KeyBook</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>publicKey</span> <code class='quiet'>((RsaPublicKey | Ed25519PublicKey | Secp256k1PublicKey))</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#keybook">KeyBook</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='keybookget'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>get(peerId)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/key-book.js#L74-L82'>
|
|
<span>src/peer-store/key-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get Public key of the given PeerId, if stored.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>get(peerId: PeerId): (RsaPublicKey | Ed25519PublicKey | Secp256k1PublicKey)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>(RsaPublicKey | Ed25519PublicKey | Secp256k1PublicKey)</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='metadatabook'>
|
|
MetadataBook
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/metadata-book.js#L22-L158'>
|
|
<span>src/peer-store/metadata-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>The MetadataBook is responsible for keeping the known supported
|
|
protocols of a peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new MetadataBook(peerStore: <a href="#peerstore">PeerStore</a>)</div>
|
|
|
|
|
|
<p>
|
|
Extends
|
|
|
|
<a href="#book">Book</a>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerStore</span> <code class='quiet'>(<a href="#peerstore">PeerStore</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='metadatabookdata'>
|
|
<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'>data</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/metadata-book.js#L42-L42'>
|
|
<span>src/peer-store/metadata-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Map known peers to their known protocols.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>data</div>
|
|
|
|
<p>
|
|
Type:
|
|
<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>, <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>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>>>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='metadatabookset'>
|
|
<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'>set(peerId, key, value)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/metadata-book.js#L53-L67'>
|
|
<span>src/peer-store/metadata-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Set metadata key and value of a provided peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>set(peerId: PeerId, key: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, value: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>): <a href="#protobook">ProtoBook</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>key</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
metadata key
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>value</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>)</code>
|
|
metadata value
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#protobook">ProtoBook</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='metadatabook_setvalue'>
|
|
<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'>_setValue(peerId, key, value, $3)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/metadata-book.js#L73-L88'>
|
|
<span>src/peer-store/metadata-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Set data into the datastructure</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>_setValue(peerId: any, key: any, value: any, $3: <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'>peerId</span> <code class='quiet'>(any)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>key</span> <code class='quiet'>(any)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>value</span> <code class='quiet'>(any)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>$3</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>
|
|
= <code>{}</code>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$3.emit</span> <code class='quiet'>any</code>
|
|
|
|
(default <code>true</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='metadatabookget'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>get(peerId)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/metadata-book.js#L95-L101'>
|
|
<span>src/peer-store/metadata-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get the known data of a provided peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>get(peerId: PeerId): <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>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="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>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='metadatabookgetvalue'>
|
|
<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'>getValue(peerId, key)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/metadata-book.js#L109-L116'>
|
|
<span>src/peer-store/metadata-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get specific metadata value, if it exists</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getValue(peerId: PeerId, key: <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/Uint8Array">Uint8Array</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>key</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/Uint8Array">Uint8Array</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='metadatabookdelete'>
|
|
<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'>delete(peerId)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/metadata-book.js#L123-L135'>
|
|
<span>src/peer-store/metadata-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Deletes the provided peer from the book.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>delete(peerId: PeerId): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</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>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='metadatabookdeletevalue'>
|
|
<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'>deleteValue(peerId, key)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/metadata-book.js#L143-L157'>
|
|
<span>src/peer-store/metadata-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Deletes the provided peer metadata key from the book.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>deleteValue(peerId: PeerId, key: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='eventproperty'>
|
|
eventProperty
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/metadata-book.js#L32-L36'>
|
|
<span>src/peer-store/metadata-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>PeerStore Event emitter, used by the MetadataBook to emit:
|
|
"change:metadata" - emitted when the known metadata of a peer change.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>eventProperty</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='protobook'>
|
|
ProtoBook
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/proto-book.js#L21-L118'>
|
|
<span>src/peer-store/proto-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>The ProtoBook is responsible for keeping the known supported
|
|
protocols of a peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new ProtoBook(peerStore: <a href="#peerstore">PeerStore</a>)</div>
|
|
|
|
|
|
<p>
|
|
Extends
|
|
|
|
<a href="#book">Book</a>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerStore</span> <code class='quiet'>(<a href="#peerstore">PeerStore</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='protobookdata'>
|
|
<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'>data</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/proto-book.js#L42-L42'>
|
|
<span>src/peer-store/proto-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Map known peers to their known protocols.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>data</div>
|
|
|
|
<p>
|
|
Type:
|
|
<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>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set">Set</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>>>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='protobookset'>
|
|
<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'>set(peerId, protocols)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/proto-book.js#L53-L81'>
|
|
<span>src/peer-store/proto-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Set known protocols of a provided peer.
|
|
If the peer was not known before, it will be added.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>set(peerId: PeerId, protocols: <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>>): <a href="#protobook">ProtoBook</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>protocols</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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#protobook">ProtoBook</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='protobookadd'>
|
|
<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(peerId, protocols)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/proto-book.js#L90-L117'>
|
|
<span>src/peer-store/proto-book.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Adds known protocols of a provided peer.
|
|
If the peer was not known before, it will be added.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>add(peerId: PeerId, protocols: <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>>): <a href="#protobook">ProtoBook</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>protocols</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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#protobook">ProtoBook</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='subscribe'>
|
|
subscribe
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/pubsub-adapter.js#L13-L17'>
|
|
<span>src/pubsub-adapter.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Subscribes to a given topic.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>subscribe(topic: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, handler: function (msg: InMessage)?): void</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>topic</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>handler</span> <code class='quiet'>(function (msg: InMessage)?)</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='unsubscribe'>
|
|
unsubscribe
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/pubsub-adapter.js#L26-L36'>
|
|
<span>src/pubsub-adapter.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Unsubscribe from the given topic.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>unsubscribe(topic: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, handler: function (msg: InMessage)?): void</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>topic</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>handler</span> <code class='quiet'>(function (msg: InMessage)?)</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='persistentpeerstore'>
|
|
PersistentPeerStore
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/persistent/index.js#L27-L347'>
|
|
<span>src/peer-store/persistent/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Responsible for managing the persistence of data in the PeerStore.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new PersistentPeerStore($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, properties: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</div>
|
|
|
|
|
|
<p>
|
|
Extends
|
|
|
|
<a href="#peerstore">PeerStore</a>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.peerId</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.datastore</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.threshold</span> <code class='quiet'>any</code>
|
|
|
|
(default <code>5</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>properties</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='persistentpeerstore_datastore'>
|
|
<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'>_datastore</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/persistent/index.js#L41-L41'>
|
|
<span>src/peer-store/persistent/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Backend datastore used to persist data.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>_datastore</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='persistentpeerstore_dirtypeers'>
|
|
<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'>_dirtyPeers</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/persistent/index.js#L46-L46'>
|
|
<span>src/peer-store/persistent/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Peers modified after the latest data persisted.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>_dirtyPeers</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='persistentpeerstore_dirtymetadata'>
|
|
<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'>_dirtyMetadata</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/persistent/index.js#L52-L52'>
|
|
<span>src/peer-store/persistent/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Peers metadata changed mapping peer identifers to metadata changed.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>_dirtyMetadata</div>
|
|
|
|
<p>
|
|
Type:
|
|
<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>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set">Set</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>>>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='persistentpeerstorestart'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>start()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/peer-store/persistent/index.js#L62-L77'>
|
|
<span>src/peer-store/persistent/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Start Persistent PeerStore.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>start(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><void></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><void></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='registrar'>
|
|
Registrar
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/registrar.js#L16-L100'>
|
|
<span>src/registrar.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Responsible for notifying registered protocols of events in the network.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new Registrar($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, props: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.peerStore</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.connectionManager</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>props</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='registrartopologies'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>topologies</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/registrar.js#L34-L34'>
|
|
<span>src/registrar.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Map of topologies</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>topologies</div>
|
|
|
|
<p>
|
|
Type:
|
|
<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map">Map</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='registrargetconnection'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>getConnection(peerId)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/registrar.js#L55-L57'>
|
|
<span>src/registrar.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get a connection with a peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getConnection(peerId: PeerId): Connection</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>Connection</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='registrarregister'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>register(topology)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/registrar.js#L64-L78'>
|
|
<span>src/registrar.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Register handlers for a set of multicodecs given</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>register(topology: Topology): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>topology</span> <code class='quiet'>(Topology)</code>
|
|
protocol topology
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code>:
|
|
registrar identifier
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='registrarunregister'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>unregister(id)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/registrar.js#L85-L87'>
|
|
<span>src/registrar.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Unregister topology.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>unregister(id: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>id</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
registrar identifier
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code>:
|
|
unregistered successfully
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='registrar_ondisconnect'>
|
|
<div class="clearfix small pointer toggle-sibling">
|
|
<div class="py1 contain">
|
|
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
|
|
<span class='code strong strong truncate'>_onDisconnect(connection, error?)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/registrar.js#L95-L99'>
|
|
<span>src/registrar.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Remove a disconnected peer from the record</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>_onDisconnect(connection: Connection, error: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>?): void</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>connection</span> <code class='quiet'>(Connection)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>error</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>?)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>void</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='ping'>
|
|
ping
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/ping/index.js#L21-L43'>
|
|
<span>src/ping/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Ping a given peer and wait for its response, getting the operation latency.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>ping(node: <a href="#libp2p">Libp2p</a>, peer: (PeerId | multiaddr)): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>node</span> <code class='quiet'>(<a href="#libp2p">Libp2p</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peer</span> <code class='quiet'>((PeerId | 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/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a>></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='mount'>
|
|
mount
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/ping/index.js#L49-L51'>
|
|
<span>src/ping/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Subscribe ping protocol handler.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>mount(node: <a href="#libp2p">Libp2p</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>node</span> <code class='quiet'>(<a href="#libp2p">Libp2p</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='unmount'>
|
|
unmount
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/ping/index.js#L57-L59'>
|
|
<span>src/ping/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Unsubscribe ping protocol handler.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>unmount(node: <a href="#libp2p">Libp2p</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>node</span> <code class='quiet'>(<a href="#libp2p">Libp2p</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='constructor'>
|
|
constructor
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/identify/index.js#L55-L85'>
|
|
<span>src/identify/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>new constructor(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.libp2p</span> <code class='quiet'><a href="#libp2p">Libp2p</a></code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.protocols</span> <code class='quiet'><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>, handler></code>
|
|
</td>
|
|
<td class='break-word'><span>A reference to the protocols we support
|
|
</span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='peerstore'>
|
|
peerStore
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/identify/index.js#L59-L59'>
|
|
<span>src/identify/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>peerStore</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='connectionmanager'>
|
|
connectionManager
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/identify/index.js#L64-L64'>
|
|
<span>src/identify/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>connectionManager</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='peerid'>
|
|
peerId
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/identify/index.js#L75-L75'>
|
|
<span>src/identify/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>peerId</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='_libp2p'>
|
|
_libp2p
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/identify/index.js#L80-L80'>
|
|
<span>src/identify/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>_libp2p</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='push'>
|
|
push
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/identify/index.js#L92-L118'>
|
|
<span>src/identify/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Send an Identify Push update to the list of connections</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>push(connections: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><Connection>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><void></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>connections</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a><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><void></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='pushtopeerstore'>
|
|
pushToPeerStore
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/identify/index.js#L124-L134'>
|
|
<span>src/identify/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Calls <code>push</code> for all peers in the <code>peerStore</code> that are connected</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>pushToPeerStore(peerStore: <a href="#peerstore">PeerStore</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerStore</span> <code class='quiet'>(<a href="#peerstore">PeerStore</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='identify'>
|
|
identify
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/identify/index.js#L145-L206'>
|
|
<span>src/identify/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Requests the <code>Identify</code> message from peer associated with the given <code>connection</code>.
|
|
If the identified peer does not match the <code>PeerId</code> associated with the connection,
|
|
an error will be thrown.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>identify(connection: Connection): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><void></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>connection</span> <code class='quiet'>(Connection)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><void></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='handlemessage'>
|
|
handleMessage
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/identify/index.js#L217-L226'>
|
|
<span>src/identify/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>A handler to register with Libp2p to process identify messages.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>handleMessage(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><void></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.connection</span> <code class='quiet'>Connection</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.stream</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.protocol</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><void></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='_getselfpeerrecord'>
|
|
_getSelfPeerRecord
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/identify/index.js#L316-L337'>
|
|
<span>src/identify/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Get self signed peer record raw envelope.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>_getSelfPeerRecord(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='getcleanmultiaddr'>
|
|
getCleanMultiaddr
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/identify/index.js#L38-L47'>
|
|
<span>src/identify/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Takes the <code>addr</code> and converts it to a Multiaddr if possible</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>getCleanMultiaddr(addr: (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)): (Multiaddr | null)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>addr</span> <code class='quiet'>((<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>))</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>(Multiaddr | null)</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='envelope'>
|
|
Envelope
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/record/envelope/index.js#L21-L83'>
|
|
<span>src/record/envelope/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>The Envelope is responsible for keeping an arbitrary signed record
|
|
by a libp2p peer.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new Envelope($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, params: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.peerId</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.payloadType</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.payload</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.signature</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>params</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Static Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='envelopecreatefromprotobuf'>
|
|
<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'>createFromProtobuf(data)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/record/envelope/index.js#L121-L131'>
|
|
<span>src/record/envelope/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Unmarshal a serialized Envelope protobuf message.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>createFromProtobuf(data: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="#envelope">Envelope</a>></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>data</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</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><<a href="#envelope">Envelope</a>></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='envelopeseal'>
|
|
<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'>seal(record, peerId)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/record/envelope/index.js#L141-L155'>
|
|
<span>src/record/envelope/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Seal marshals the given Record, places the marshaled bytes inside an Envelope
|
|
and signs it with the given peerId's private key.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>seal(record: Record, peerId: PeerId): <a href="#envelope">Envelope</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>record</span> <code class='quiet'>(Record)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>peerId</span> <code class='quiet'>(PeerId)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#envelope">Envelope</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='envelopeopenandcertify'>
|
|
<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'>openAndCertify(data, domain)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/record/envelope/index.js#L164-L173'>
|
|
<span>src/record/envelope/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Open and certify a given marshalled envelope.
|
|
Data is unmarshalled and the signature validated for the given domain.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>openAndCertify(data: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>, domain: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="#envelope">Envelope</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>data</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>domain</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="#envelope">Envelope</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='envelopemarshal'>
|
|
<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'>marshal()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/record/envelope/index.js#L44-L59'>
|
|
<span>src/record/envelope/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Marshal the envelope content.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>marshal(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='envelopeequals'>
|
|
<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'>equals(other)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/record/envelope/index.js#L66-L71'>
|
|
<span>src/record/envelope/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Verifies if the other Envelope is identical to this one.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>equals(other: <a href="#envelope">Envelope</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>other</span> <code class='quiet'>(<a href="#envelope">Envelope</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/Boolean">boolean</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='envelopevalidate'>
|
|
<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'>validate(domain)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/record/envelope/index.js#L78-L82'>
|
|
<span>src/record/envelope/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Validate envelope data signature for the given domain.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>validate(domain: <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><<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'>domain</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><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='formatsignaturepayload'>
|
|
formatSignaturePayload
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/record/envelope/index.js#L92-L114'>
|
|
<span>src/record/envelope/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Helper function that prepares a Uint8Array to sign or verify a signature.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>formatSignaturePayload</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>domain</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'>payloadType</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>payload</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</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/Uint8Array">Uint8Array</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='peerrecord'>
|
|
PeerRecord
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/record/peer-record/index.js#L18-L80'>
|
|
<span>src/record/peer-record/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>The PeerRecord is used for distributing peer routing records across the network.
|
|
It contains the peer's reachable listen addresses.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>new PeerRecord($0: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, params: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</div>
|
|
|
|
|
|
<p>
|
|
Extends
|
|
|
|
Record
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>$0</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.peerId</span> <code class='quiet'>any</code>
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.multiaddrs</span> <code class='quiet'>any</code>
|
|
|
|
(default <code>[]</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>$0.seqNumber</span> <code class='quiet'>any</code>
|
|
|
|
(default <code>Date.now()</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>params</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Static Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='peerrecordcreatefromprotobuf'>
|
|
<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'>createFromProtobuf(buf)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/record/peer-record/index.js#L87-L96'>
|
|
<span>src/record/peer-record/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Unmarshal Peer Record Protobuf.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>createFromProtobuf(buf: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>): <a href="#peerrecord">PeerRecord</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>buf</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>)</code>
|
|
marshaled peer record.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="#peerrecord">PeerRecord</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
|
|
<div class="clearfix">
|
|
|
|
<div class='border-bottom' id='peerrecordmarshal'>
|
|
<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'>marshal()</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/record/peer-record/index.js#L41-L55'>
|
|
<span>src/record/peer-record/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Marshal a record to be used in an envelope.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>marshal(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class='border-bottom' id='peerrecordequals'>
|
|
<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'>equals(other)</span>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix display-none toggle-target">
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p/blob/32e7a83c39530233998dcd3878a8bb5facc05a56/src/record/peer-record/index.js#L62-L79'>
|
|
<span>src/record/peer-record/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Returns true if <code>this</code> record equals the <code>other</code>.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>equals(other: Record): <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'>other</span> <code class='quiet'>(Record)</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>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<script src='assets/anchor.js'></script>
|
|
<script src='assets/split.js'></script>
|
|
<script src='assets/site.js'></script>
|
|
</body>
|
|
</html>
|