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
Copy file name to clipboardexpand all lines: README.md
+59-3
Original file line number
Diff line number
Diff line change
@@ -107,29 +107,78 @@ class Node extends libp2p {
107
107
108
108
### API
109
109
110
-
#### Create a Node - `new libp2p.Node()`
110
+
#### Create a Node - `new libp2p.Node([peerInfo, peerBook, options])`
111
+
112
+
> Creates an instance of the libp2p.Node.
113
+
114
+
-`peerInfo`: instance of [PeerInfo][] that contains the [PeerId][], Keys and [multiaddrs][multiaddr] of the libp2p Node. Optional.
115
+
-`peerBook`: instance of [PeerBook][] that contains the [PeerInfo][] of known peers. Optional.
116
+
-`options`: Object containing custom options for the bundle.
111
117
112
118
#### `libp2p.start(callback)`
113
119
120
+
> Start the libp2p Node.
121
+
122
+
`callback` is a function with the following `function (err) {}` signature, where `err` is an Error in case starting the node fails.
123
+
114
124
#### `libp2p.stop(callback)`
115
125
126
+
> Stop the libp2p Node.
127
+
128
+
`callback` is a function with the following `function (err) {}` signature, where `err` is an Error in case stopping the node fails.
129
+
116
130
#### `libp2p.dial(peer [, protocol, callback])`
117
131
132
+
> Dials to another peer in the network.
133
+
134
+
-`peer`: can be an instance of [PeerInfo][], [PeerId][] or [multiaddr][]
135
+
-`protocol`: String that defines the protocol (e.g '/ipfs/bitswap/1.1.0')
136
+
137
+
`callback` is a function with the following `function (err, conn) {}` signature, where `err` is an Error in of failure to dial the connection and `conn` is a [Connection][] instance in case of a protocol selected, if not it is undefined.
138
+
118
139
#### `libp2p.hangUp(peer, callback)
119
140
141
+
> Closes an open connection with a peer, graciously.
142
+
143
+
-`peer`: can be an instance of [PeerInfo][], [PeerId][] or [multiaddr][]
144
+
145
+
`callback` is a function with the following `function (err) {}` signature, where `err` is an Error in case stopping the node fails.
0 commit comments