Intro
Installable via npm install --save libp2p
, it can also be used directly in the browser.
Download
The source is available for download from GitHub. Alternatively, you can install using npm:
$ npm install --save libp2p@@ -196,1411 +64,66 @@
- Libp2p -
- - - - src/index.js - - -- Extends - - EventEmitter - -
- - - - - - - - - - -(any)
-
- Overrides EventEmitter.emit to conditionally emit errors +
Libp2p
Parameters
_options: any
:
instance
Libp2p.prototype.emit
emit(eventName: string, args: ...any): void
Overrides EventEmitter.emit to conditionally emit errors if there is a handler. If not, errors will be logged.
- -(string)
-
- (...any)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Starts the libp2p node and all sub services
- -(function (Error)
- = ()=>{}
)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Stop the libp2p node by closing its listeners and open connections
- -(function (Error)
- = ()=>{}
)
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Dials to the provided peer. If successful, the PeerInfo
of the
+
Parameters
eventName: string
:args: ...any
:
Returns
void
+Libp2p.prototype.start
start(callback: function (Error)): void
Starts the libp2p node and all sub services
+Parameters
callback: function (Error) (=()=>{})
:
Returns
void
+Libp2p.prototype.stop
stop(callback: function (Error)): void
Stop the libp2p node by closing its listeners and open connections
+Parameters
callback: function (Error) (=()=>{})
:
Returns
void
+Libp2p.prototype.dial
dial(peer: (PeerInfo | PeerId | Multiaddr | string), callback: function (Error)): void
Dials to the provided peer. If successful, the PeerInfo
of the
peer will be added to the nodes PeerBook
((PeerInfo | PeerId | Multiaddr | string))
- The peer to dial
-
- (function (Error))
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Dials to the provided peer and handshakes with the given protocol. +
Parameters
Returns
void
+Libp2p.prototype.dialProtocol
dialProtocol(peer: (PeerInfo | PeerId | Multiaddr | string), protocol: string, callback: function (Error, Connection)): void
Dials to the provided peer and handshakes with the given protocol.
If successful, the PeerInfo
of the peer will be added to the nodes PeerBook
,
and the Connection
will be sent in the callback
((PeerInfo | PeerId | Multiaddr | string))
- The peer to dial
-
- (string)
-
- (function (Error, Connection))
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Similar to dial
and dialProtocol
, but the callback will contain a
+
Parameters
Returns
void
+Libp2p.prototype.dialFSM
dialFSM(peer: (PeerInfo | PeerId | Multiaddr | string), protocol: string, callback: function (Error, ConnectionFSM)): void
Similar to dial
and dialProtocol
, but the callback will contain a
Connection State Machine.
((PeerInfo | PeerId | Multiaddr | string))
- The peer to dial
-
- (string)
-
- (function (Error, ConnectionFSM))
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Disconnects from the given peer
- - - - - - - - - - - - - -((PeerInfo | PeerId | Multiaddr | string))
- The peer to ping
-
- (function (Error))
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Pings the provided peer
- - - - - - - - - - - - - -((PeerInfo | PeerId | Multiaddr | string))
- The peer to ping
-
- (function (Error, Ping))
-
- void
:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-- createLibp2p -
- - - - src/index.js - - -Like new Libp2p(options)
except it will create a PeerInfo
+
Parameters
Returns
void
+