fix: add transport manager to exports map and fix docs (#1182)

Addresses PR comments from #1172 - fixes syntax of examples in docs, adds the transport manager to the exports map and renames fault tolerance enum for consistency.
This commit is contained in:
Alex Potsides
2022-03-29 15:39:50 +01:00
committed by GitHub
parent 8cca8e4bfc
commit cc60cfde1a
9 changed files with 26 additions and 24 deletions

View File

@ -49,13 +49,13 @@ Protocol registration is very similar to how it previously was, however, the han
**Before**
```js
const pull from 'pull-stream')
const pull = require('pull-stream')
libp2p.handle('/echo/1.0.0', (protocol, conn) => pull(conn, conn))
```
**After**
```js
const pipe from 'it-pipe')
const pipe = require('it-pipe')
libp2p.handle(['/echo/1.0.0'], ({ protocol, stream }) => pipe(stream, stream))
```
@ -65,7 +65,7 @@ libp2p.handle(['/echo/1.0.0'], ({ protocol, stream }) => pipe(stream, stream))
**Before**
```js
const pull from 'pull-stream')
const pull = require('pull-stream')
libp2p.dialProtocol(peerInfo, '/echo/1.0.0', (err, conn) => {
if (err) { throw err }
pull(
@ -82,7 +82,7 @@ libp2p.dialProtocol(peerInfo, '/echo/1.0.0', (err, conn) => {
**After**
```js
const pipe from 'it-pipe')
const pipe = require('it-pipe')
const { protocol, stream } = await libp2p.dialProtocol(peerInfo, '/echo/1.0.0')
await pipe(
['hey'],