Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into feat/dag-api
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias authored Jan 31, 2017
2 parents 44af576 + 00fe0f7 commit eab222e
Show file tree
Hide file tree
Showing 8 changed files with 747 additions and 13 deletions.
10 changes: 7 additions & 3 deletions API/files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ files API
##### `Go` **WIP**

##### `JavaScript` - ipfs.files.add(data, [callback])
##### `JavaScript` - ipfs.files.add(data, [options], [callback])

Where `data` may be

Expand All @@ -23,6 +23,8 @@ Where `data` may be

If no `content` is passed, then the path is treated as an empty directory

`options` is an optional object argument containing the [DAG importer options](https://github.com/ipfs/js-ipfs-unixfs-engine#importer-api).

`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful. `res` will be an array of:

```js
Expand Down Expand Up @@ -56,7 +58,7 @@ ipfs.files.add(files, function (err, files) {
##### `Go` **WIP**

##### `JavaScript` - ipfs.files.createAddStream([callback])
##### `JavaScript` - ipfs.files.createAddStream([options], [callback])

Provides a Transform stream, where objects can be written of the forms

Expand All @@ -67,6 +69,8 @@ Provides a Transform stream, where objects can be written of the forms
}
```

`options` is an optional object argument containing the [DAG importer options](https://github.com/ipfs/js-ipfs-unixfs-engine#importer-api).

`callback` must follow `function (err, stream) {}` signature, where `err` is an
error if the operation was not successful. `stream` will be a Transform stream,
to which tuples like the above two object formats can be written and [DAGNode][]
Expand Down Expand Up @@ -105,7 +109,7 @@ ipfs.files.createAddStream(function (err, stream) {

`multihash` is a [multihash][] which can be passed as

- Buffer, the raw Buffer of the multihash
- Buffer, the raw Buffer of the multihash
- String, the base58 encoded version of the multihash

`callback` must follow `function (err, stream) {}` signature, where `err` is an error if the operation was not successful and `stream` is a readable stream of the file.
Expand Down
73 changes: 73 additions & 0 deletions API/pubsub/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
pubsub API
==========

#### `pubsub.subscribe`

> Subscribe to a pubsub topic.
##### `Go` **WIP**

##### `JavaScript` - ipfs.pubsub.subscribe(topic, options, handler, callback)

- `topic: string`
- `options: Object` - (Optional), might contain the following properties:
- `discover`: type: Boolean - Will use the DHT to find other peers.
- `handler: (msg) => ()` - Event handler which will be called with a message object everytime one is received. The `msg` has the format `{from: string, seqno: Buffer, data: Buffer, topicCIDs: Array<string>}`.
- `callback: (Error) => ()` (Optional) Called once the subscription is established.

If no `callback` is passed, a [promise][] is returned.

> _In the future, topic can also be type of TopicDescriptor (https://github.com/libp2p/pubsub-notes/blob/master/flooding/flooding.proto#L23). However, for now, only strings are supported._
#### `pubsub.unsubscribe`

> Unsubscribes from a pubsub topic.
##### `Go` **WIP**

##### `JavaScript` - `ipfs.pubsub.unsubscribe(topic, handler)`

- `topic: string` - The topic to unsubscribe from
- `handler: (msg) => ()` - The handler to remove.

This works like `EventEmitter.removeListener`, as that only the `handler` passed to a `subscribe` call before is removed from listening. The underlying subscription will only be canceled once all listeners for a topic have been removed.

#### `pubsub.publish`

> Publish a data message to a pubsub topic.
##### `Go` **WIP**

##### `JavaScript` - ipfs.pubsub.publish(topic, data, callback)

- `topic: string`
- `data: buffer` - The actual message to send
- `callback: (Error) => ()` - Calls back with an error or nothing if the publish was successfull.

If no `callback` is passed, a promise is returned.

#### `pubsub.ls`

> Returns the list of subscriptions the peer is subscribed to.
##### `Go` **WIP**

##### `JavaScript` - ipfs.pubsub.ls(topic, callback)

- `topic: string`
- `callback: (Error, Array<string>>) => ()` - Calls back with an error or a list of topicCIDs that this peer is subscribed to.

If no `callback` is passed, a promise is returned.

#### `pubsub.peers`

> Returns the peers that are subscribed to one topic.
##### `Go` **WIP**

##### `JavaScript` - ipfs.pubsub.peers(topic, callback)

- `topic: string`
- `callback: (Error, Array<string>>) => ()` - Calls back with an error or a list of peer ids subscribed to the `topic`.

If no `callback` is passed, a promise is returned.
61 changes: 61 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,64 @@
<a name="0.23.5"></a>
## [0.23.5](https://github.com/ipfs/interface-ipfs-core/compare/v0.23.4...v0.23.5) (2017-01-17)



<a name="0.23.4"></a>
## [0.23.4](https://github.com/ipfs/interface-ipfs-core/compare/v0.23.3...v0.23.4) (2017-01-17)


### Bug Fixes

* **config:** make promise tests actually test the full promise chain ([416560e](https://github.com/ipfs/interface-ipfs-core/commit/416560e))



<a name="0.23.3"></a>
## [0.23.3](https://github.com/ipfs/interface-ipfs-core/compare/v0.23.2...v0.23.3) (2017-01-16)


### Bug Fixes

* **test:** send/receive 10k messages test ([ad952e2](https://github.com/ipfs/interface-ipfs-core/commit/ad952e2))



<a name="0.23.2"></a>
## [0.23.2](https://github.com/ipfs/interface-ipfs-core/compare/v0.23.1...v0.23.2) (2017-01-11)


### Bug Fixes

* be nodejs 4 compatible ([3e356f0](https://github.com/ipfs/interface-ipfs-core/commit/3e356f0))



<a name="0.23.1"></a>
## [0.23.1](https://github.com/ipfs/interface-ipfs-core/compare/v0.23.0...v0.23.1) (2017-01-11)


### Bug Fixes

* identify needs time to finish ([b76993d](https://github.com/ipfs/interface-ipfs-core/commit/b76993d))



<a name="0.23.0"></a>
# [0.23.0](https://github.com/ipfs/interface-ipfs-core/compare/v0.22.1...v0.23.0) (2016-12-21)


### Bug Fixes

* fix a bunch of issues (i.e: identify race condition) ([d004577](https://github.com/ipfs/interface-ipfs-core/commit/d004577))


### Features

* add first pass of pubsub tests (running in js-ipfs-api) ([74003a7](https://github.com/ipfs/interface-ipfs-core/commit/74003a7))
* new event based API ([1a82890](https://github.com/ipfs/interface-ipfs-core/commit/1a82890))



<a name="0.22.1"></a>
## [0.22.1](https://github.com/ipfs/interface-ipfs-core/compare/v0.22.0...v0.22.1) (2016-12-10)

Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "interface-ipfs-core",
"version": "0.22.1",
"version": "0.23.5",
"description": "A test suite and interface you can use to implement a IPFS core interface.",
"main": "src/index.js",
"scripts": {
Expand All @@ -27,12 +27,12 @@
"homepage": "https://github.com/ipfs/interface-ipfs-core#readme",
"dependencies": {
"async": "^2.1.4",
"bl": "^1.1.2",
"bs58": "^3.1.0",
"bl": "^1.2.0",
"bs58": "^4.0.0",
"chai": "^3.5.0",
"concat-stream": "^1.5.2",
"concat-stream": "^1.6.0",
"detect-node": "^2.0.3",
"ipfs-block": "^0.5.3",
"ipfs-block": "^0.5.4",
"ipld-dag-pb": "^0.9.3",
"multiaddr": "^2.1.1",
"multihashes": "^0.3.1",
Expand All @@ -44,10 +44,12 @@
"contributors": [
"David Dias <daviddias.p@gmail.com>",
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
"Pedro Teixeira <i@pgte.me>",
"Richard Littauer <richard.littauer@gmail.com>",
"Stephen Whitmore <stephen.whitmore@gmail.com>",
"Victor Bjelkholm <victorbjelkholm@gmail.com>",
"greenkeeperio-bot <support@greenkeeper.io>",
"haad <haad@headbanggames.com>",
"nginnever <ginneversource@gmail.com>"
]
}
8 changes: 3 additions & 5 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,9 @@ module.exports = (common) => {
describe('.set', () => {
it('set a new key', () => {
return ipfs.config.set('Fruit', 'banana')
.then(() => {
ipfs.config.get('Fruit', (err, fruit) => {
expect(err).to.not.exist
expect(fruit).to.equal('banana')
})
.then(() => ipfs.config.get('Fruit'))
.then((fruit) => {
expect(fruit).to.equal('banana')
})
})
})
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ exports.swarm = require('./swarm')
exports.block = require('./block')
exports.dht = require('./dht')
exports.dag = require('./dag')
exports.pubsub = require('./pubsub')
Loading

0 comments on commit eab222e

Please sign in to comment.