|
28 | 28 | * [`metrics.protocols`](#metricsprotocols)
|
29 | 29 | * [`metrics.forPeer`](#metricsforpeer)
|
30 | 30 | * [`metrics.forProtocol`](#metricsforprotocol)
|
| 31 | +* [Events](#events) |
31 | 32 | * [Types](#types)
|
32 | 33 | * [`Stats`](#stats)
|
33 | 34 |
|
@@ -96,39 +97,6 @@ Required keys in the `options` object:
|
96 | 97 |
|
97 | 98 | </details>
|
98 | 99 |
|
99 |
| -Once you have a libp2p instance, you are able to listen to several events it emits, so that you can be noticed of relevant network events. |
100 |
| - |
101 |
| -<details><summary>Events</summary> |
102 |
| - |
103 |
| -#### An error has occurred |
104 |
| - |
105 |
| -`libp2p.on('error', (err) => {})` |
106 |
| - |
107 |
| -- `err`: instance of `Error` |
108 |
| - |
109 |
| -#### A peer has been discovered |
110 |
| - |
111 |
| -`libp2p.on('peer:discovery', (peer) => {})` |
112 |
| - |
113 |
| -If `autoDial` option is `true`, applications should **not** attempt to connect to the peer |
114 |
| -unless they are performing a specific action. See [peer discovery and auto dial](./PEER_DISCOVERY.md) for more information. |
115 |
| - |
116 |
| -- `peer`: instance of [PeerInfo][https://github.com/libp2p/js-peer-info] |
117 |
| - |
118 |
| -#### We have a new connection to a peer |
119 |
| - |
120 |
| -`libp2p.on('peer:connect', (peer) => {})` |
121 |
| - |
122 |
| -- `peer`: instance of [PeerInfo][https://github.com/libp2p/js-peer-info] |
123 |
| - |
124 |
| -#### We have closed a connection to a peer |
125 |
| - |
126 |
| -`libp2p.on('peer:disconnect', (peer) => {})` |
127 |
| - |
128 |
| -- `peer`: instance of [PeerInfo][https://github.com/libp2p/js-peer-info] |
129 |
| - |
130 |
| -</details> |
131 |
| - |
132 | 100 | ## Libp2p Instance Methods
|
133 | 101 |
|
134 | 102 | ### start
|
@@ -777,6 +745,37 @@ const peerStats = libp2p.metrics.forProtocol('/meshsub/1.0.0')
|
777 | 745 | console.log(peerStats.toJSON())
|
778 | 746 | ```
|
779 | 747 |
|
| 748 | +## Events |
| 749 | + |
| 750 | +Once you have a libp2p instance, you are able to listen to several events it emits, so that you can be noticed of relevant network events. |
| 751 | + |
| 752 | +#### An error has occurred |
| 753 | + |
| 754 | +`libp2p.on('error', (err) => {})` |
| 755 | + |
| 756 | +- `err`: instance of `Error` |
| 757 | + |
| 758 | +#### A peer has been discovered |
| 759 | + |
| 760 | +`libp2p.on('peer:discovery', (peer) => {})` |
| 761 | + |
| 762 | +If `autoDial` option is `true`, applications should **not** attempt to connect to the peer |
| 763 | +unless they are performing a specific action. See [peer discovery and auto dial](./PEER_DISCOVERY.md) for more information. |
| 764 | + |
| 765 | +- `peer`: instance of [PeerInfo][https://github.com/libp2p/js-peer-info] |
| 766 | + |
| 767 | +#### We have a new connection to a peer |
| 768 | + |
| 769 | +`libp2p.on('peer:connect', (peer) => {})` |
| 770 | + |
| 771 | +- `peer`: instance of [PeerInfo][https://github.com/libp2p/js-peer-info] |
| 772 | + |
| 773 | +#### We have closed a connection to a peer |
| 774 | + |
| 775 | +`libp2p.on('peer:disconnect', (peer) => {})` |
| 776 | + |
| 777 | +- `peer`: instance of [PeerInfo][https://github.com/libp2p/js-peer-info] |
| 778 | + |
780 | 779 | ## Types
|
781 | 780 |
|
782 | 781 | ### Stats
|
|
0 commit comments