You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: The `PeerInfo` option is not required and will be generated if it is not provided.
57
57
58
+
<details><summary>Alternative</summary>
58
59
As an alternative, it is possible to create a Libp2p instance with the constructor:
59
60
60
61
#### Example
@@ -71,9 +72,11 @@ const libp2p = new Libp2p(options)
71
72
72
73
Required keys in the `options` object:
73
74
74
-
-`peerInfo`: instance of [PeerInfo][] that contains the [PeerId][], Keys and [multiaddrs][multiaddr] of the libp2p Node.
75
+
-`peerInfo`: instance of [PeerInfo][] that contains the [PeerId][], Keys and [multiaddrs][multiaddr] of the libp2p Node (optional when using `.create`).
75
76
-`modules.transport`: An array that must include at least 1 compliant transport. See [modules that implement the transport interface](https://github.com/libp2p/js-interfaces/tree/master/src/transport#modules-that-implement-the-interface).
76
77
78
+
</details>
79
+
77
80
## Libp2p Instance Methods
78
81
79
82
### start
@@ -151,11 +154,19 @@ Dials to another peer in the network and establishes the connection.
// protocol negotiated: 'echo/1.0.0' means that the other party only supports the older version
162
+
163
+
// ...
164
+
awaitconn.close()
154
165
```
155
166
156
167
### dialProtocol
157
168
158
-
Dials to another peer in the network and selects a protocol to communicate with that peer.
169
+
Dials to another peer in the network and selects a protocol to communicate with that peer. The stream between both parties is returned, together with the negotiated protocol.
159
170
160
171
`dialProtocol(peer, protocols, options)`
161
172
@@ -172,13 +183,18 @@ Dials to another peer in the network and selects a protocol to communicate with
172
183
173
184
| Type | Description |
174
185
|------|-------------|
175
-
|`Promise<Connection>`| Promise resolves with the [Connection](https://github.com/libp2p/js-interfaces/tree/master/src/connection) instance|
186
+
|`Promise<{ stream:*, protocol:string }>`| Promise resolves with a [duplex stream](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#duplex-it) and the protocol used|
0 commit comments