Skip to content

Commit

Permalink
chore: update deps (#18)
Browse files Browse the repository at this point in the history
* chore: update deps

BREAKING CHANGE: api changed as attach is not needed anymore

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <[email protected]>

* chore: update aegir

* chore: update daemon version

Co-authored-by: Jacob Heun <[email protected]>
  • Loading branch information
vasco-santos and jacobheun authored Jan 31, 2020
1 parent 9a87bbf commit 61813b9
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 450 deletions.
60 changes: 0 additions & 60 deletions API.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# API

* [Getting started](#getting-started)
* [`attach`](#attach)
* [`close`](#close)
* [`connect`](#connect)
* [`identify`](#identify)
Expand Down Expand Up @@ -46,32 +45,6 @@ const client = new Client(defaultSock)
// client.{}
```

## attach

Connects to a daemon at the unix socket path the daemon was created with.

### `client.attach()`

#### Returns

| Type | Description |
|------|-------------|
| `Promise` | Promise resolves when connection is achieved |

#### Example

```js
const Client = require('libp2p-daemon-client')

const defaultSock = '/tmp/p2pd.sock'
const client = new Client(defaultSock)

// connect to a daemon
await client.attach()
```

NOTE: when attaching the client, the socket must be closed afterwards.

## close

Closes the socket.
Expand All @@ -92,9 +65,6 @@ const Client = require('libp2p-daemon-client')
const defaultSock = '/tmp/p2pd.sock'
const client = new Client(defaultSock)

// connect to a daemon
await client.attach()

// close the socket
await client.close()
```
Expand All @@ -117,8 +87,6 @@ Requests a connection to a known peer on a given set of addresses.
```js
const client = new Client(defaultSock)

await client.attach()

try {
await client.connect(peerId, addrs)
} catch (err) {
Expand All @@ -145,8 +113,6 @@ Query the daemon for its peer ID and listen addresses.
```js
const client = new Client(defaultSock)

await client.attach()

let identify

try {
Expand Down Expand Up @@ -174,8 +140,6 @@ Get a list of IDs of peers the node is connected to.
```js
const client = new Client(defaultSock)

await client.attach()

let identify

try {
Expand Down Expand Up @@ -210,8 +174,6 @@ Initiate an outbound stream to a peer on one of a set of protocols.
const protocol = '/protocol/1.0.0'
const client = new Client(defaultSock)

await client.attach()

let socket

try {
Expand Down Expand Up @@ -242,8 +204,6 @@ Register a handler for inbound streams on a given protocol.
const protocol = '/protocol/1.0.0'
const client = new Client(defaultSock)

await client.attach()

await client.registerStreamHandler(path, protocol)
```

Expand All @@ -265,8 +225,6 @@ Write a value to a key in the DHT.
```js
const client = new Client(defaultSock)

await client.attach()

const key = '/key'
const value = Buffer.from('oh hello there')

Expand Down Expand Up @@ -300,8 +258,6 @@ Query the DHT for a value stored through a key in the DHT.
```js
const client = new Client(defaultSock)

await client.attach()

const key = '/key'
let value

Expand Down Expand Up @@ -335,8 +291,6 @@ Query the DHT for a given peer's known addresses.
```js
const client = new Client(defaultSock)

await client.attach()

let peerInfo

try {
Expand All @@ -363,8 +317,6 @@ Announce that have data addressed by a given CID.
```js
const client = new Client(defaultSock)

await client.attach()

try {
await client.dht.provide(cid)
} catch (err) {
Expand Down Expand Up @@ -397,8 +349,6 @@ Query the DHT for peers that have a piece of content, identified by a CID.
```js
const client = new Client(defaultSock)

await client.attach()

let peerInfos

try {
Expand Down Expand Up @@ -432,8 +382,6 @@ Query the DHT routing table for peers that are closest to a provided key.
```js
const client = new Client(defaultSock)

await client.attach()

let peerInfos

try {
Expand Down Expand Up @@ -466,8 +414,6 @@ Query the DHT routing table for a given peer's public key.
```js
const client = new Client(defaultSock)

await client.attach()

let publicKey

try {
Expand All @@ -490,8 +436,6 @@ try {
```js
const client = new Client(defaultSock)

await client.attach()

let topics

try {
Expand Down Expand Up @@ -523,8 +467,6 @@ const topic = 'topic'
const data = Buffer.from('data')
const client = new Client(defaultSock)

await client.attach()

try {
await client.pubsub.publish(topic, data)
} catch (err) {
Expand Down Expand Up @@ -552,8 +494,6 @@ try {
const topic = 'topic'
const client = new Client(defaultSock)

await client.attach()

for await (const msg of client.pubsub.subscribe(topic)) {
// msg.data - pubsub data received
}
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ const Client = require('libp2p-daemon-client')
const defaultSock = '/tmp/p2pd.sock'
const client = new Client(defaultSock)

// connect to a daemon
await client.attach()

// interact with the daemon
let identify
try {
Expand All @@ -64,7 +61,6 @@ await client.close()
## API

* [Getting started](API.md#getting-started)
* [`attach`](API.md#attach)
* [`close`](API.md#close)
* [`connect`](API.md#connect)
* [`identify`](API.md#identify)
Expand Down
23 changes: 14 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,28 @@
],
"license": "MIT",
"devDependencies": {
"aegir": "^20.0.0",
"aegir": "^20.5.1",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"chai-bytes": "~0.1.2",
"dirty-chai": "^2.0.1",
"mocha": "^6.2.0",
"sinon": "^7.4.2"
"it-buffer": "^0.1.1",
"it-pipe": "^1.1.0",
"it-pushable": "^1.4.0",
"mocha": "^6.2.2",
"sinon": "^7.5.0",
"streaming-iterables": "^4.1.1"
},
"dependencies": {
"cids": "~0.7.1",
"err-code": "^2.0.0",
"length-prefixed-stream": "github:jacobheun/length-prefixed-stream#v2.0.0-rc.1",
"libp2p-daemon": "~0.2.3",
"multiaddr": "^7.0.0",
"peer-id": "~0.12.2",
"peer-info": "~0.15.1",
"stream-to-iterator": "^3.0.2-0"
"it-handshake": "^1.0.1",
"it-length-prefixed": "^3.0.0",
"libp2p-daemon": "^0.3.0",
"libp2p-tcp": "^0.14.2",
"multiaddr": "^7.2.1",
"peer-id": "~0.13.3",
"peer-info": "~0.17.0"
},
"contributors": [
"Arve Knudsen <[email protected]>",
Expand Down
Loading

0 comments on commit 61813b9

Please sign in to comment.