Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
docs: update README to the latest changes (#169)
Browse files Browse the repository at this point in the history
* docs: update links to libp2p-interfaces in README

Also I see that there are 3 separate sections about contributing that duplicate each other. Should I merge them into one in this PR?

* fix import in the example of README.md

* update the README example to the latest API
  • Loading branch information
vogdb authored Apr 5, 2022
1 parent ecbf5df commit 129bf19
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[![](https://github.com/raw/libp2p/js-libp2p-interfaces/master/src/transport/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/transport)
[![](https://github.com/raw/libp2p/js-libp2p-interfaces/master/src/connection/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/connection)

> JavaScript implementation of the TCP module for libp2p. It exposes the [interface-transport](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/transport) for dial/listen. `libp2p-tcp` is a very thin shim that adds support for dialing to a `multiaddr`. This small shim will enable libp2p to use other transports.
> JavaScript implementation of the TCP module for libp2p. It exposes the [interface-transport](https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-interfaces/src/transport) for dial/listen. `libp2p-tcp` is a very thin shim that adds support for dialing to a `multiaddr`. This small shim will enable libp2p to use other transports.
## Table of Contents <!-- omit in toc -->

Expand All @@ -39,8 +39,8 @@

```js
import { TCP } from '@libp2p/tcp'
import { Multiaddr } from '@multiformats/multiaddr'
import pipe from 'it-pipe'
import { multiaddr } from '@multiformats/multiaddr'
import {pipe} from 'it-pipe'
import all from 'it-all'

// A simple upgrader that just returns the MultiaddrConnection
Expand All @@ -51,12 +51,14 @@ const upgrader = {

const tcp = new TCP({ upgrader })

const listener = tcp.createListener({}, (socket) => {
console.log('new connection opened')
pipe(
['hello'],
socket
)
const listener = tcp.createListener({
handler: (socket) => {
console.log('new connection opened')
pipe(
['hello', ' ', 'World!'],
socket
)
}
})

const addr = multiaddr('/ip4/127.0.0.1/tcp/9090')
Expand All @@ -79,14 +81,14 @@ Outputs:
```sh
listening
new connection opened
Value: hello
Value: hello World!
```

## API

### Transport

[![](https://github.com/raw/libp2p/js-libp2p-interfaces/master/src/transport/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/transport)
[![](https://github.com/raw/libp2p/js-libp2p-interfaces/master/packages/libp2p-interfaces/src/transport/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-interfaces/src/transport)

`libp2p-tcp` accepts TCP addresses as both IPFS and non IPFS encapsulated addresses, i.e:

Expand All @@ -97,7 +99,7 @@ Value: hello

### Connection

[![](https://github.com/raw/libp2p/js-libp2p-interfaces/master/src/connection/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/connection)
[![](https://github.com/raw/libp2p/js-libp2p-interfaces/master/packages/libp2p-interfaces/src/connection/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-interfaces/src/connection)

## Contribute

Expand Down

0 comments on commit 129bf19

Please sign in to comment.