Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit eab222e

Browse files
authored
Merge branch 'master' into feat/dag-api
2 parents 44af576 + 00fe0f7 commit eab222e

File tree

8 files changed

+747
-13
lines changed

8 files changed

+747
-13
lines changed

API/files/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ files API
77
88
##### `Go` **WIP**
99

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

1212
Where `data` may be
1313

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

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

26+
`options` is an optional object argument containing the [DAG importer options](https://github.com/ipfs/js-ipfs-unixfs-engine#importer-api).
27+
2628
`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful. `res` will be an array of:
2729

2830
```js
@@ -56,7 +58,7 @@ ipfs.files.add(files, function (err, files) {
5658
5759
##### `Go` **WIP**
5860

59-
##### `JavaScript` - ipfs.files.createAddStream([callback])
61+
##### `JavaScript` - ipfs.files.createAddStream([options], [callback])
6062

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

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

72+
`options` is an optional object argument containing the [DAG importer options](https://github.com/ipfs/js-ipfs-unixfs-engine#importer-api).
73+
7074
`callback` must follow `function (err, stream) {}` signature, where `err` is an
7175
error if the operation was not successful. `stream` will be a Transform stream,
7276
to which tuples like the above two object formats can be written and [DAGNode][]
@@ -105,7 +109,7 @@ ipfs.files.createAddStream(function (err, stream) {
105109

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

108-
- Buffer, the raw Buffer of the multihash
112+
- Buffer, the raw Buffer of the multihash
109113
- String, the base58 encoded version of the multihash
110114

111115
`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.

API/pubsub/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
pubsub API
2+
==========
3+
4+
#### `pubsub.subscribe`
5+
6+
> Subscribe to a pubsub topic.
7+
8+
##### `Go` **WIP**
9+
10+
##### `JavaScript` - ipfs.pubsub.subscribe(topic, options, handler, callback)
11+
12+
- `topic: string`
13+
- `options: Object` - (Optional), might contain the following properties:
14+
- `discover`: type: Boolean - Will use the DHT to find other peers.
15+
- `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>}`.
16+
- `callback: (Error) => ()` (Optional) Called once the subscription is established.
17+
18+
If no `callback` is passed, a [promise][] is returned.
19+
20+
> _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._
21+
22+
#### `pubsub.unsubscribe`
23+
24+
> Unsubscribes from a pubsub topic.
25+
26+
##### `Go` **WIP**
27+
28+
##### `JavaScript` - `ipfs.pubsub.unsubscribe(topic, handler)`
29+
30+
- `topic: string` - The topic to unsubscribe from
31+
- `handler: (msg) => ()` - The handler to remove.
32+
33+
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.
34+
35+
#### `pubsub.publish`
36+
37+
> Publish a data message to a pubsub topic.
38+
39+
##### `Go` **WIP**
40+
41+
##### `JavaScript` - ipfs.pubsub.publish(topic, data, callback)
42+
43+
- `topic: string`
44+
- `data: buffer` - The actual message to send
45+
- `callback: (Error) => ()` - Calls back with an error or nothing if the publish was successfull.
46+
47+
If no `callback` is passed, a promise is returned.
48+
49+
#### `pubsub.ls`
50+
51+
> Returns the list of subscriptions the peer is subscribed to.
52+
53+
##### `Go` **WIP**
54+
55+
##### `JavaScript` - ipfs.pubsub.ls(topic, callback)
56+
57+
- `topic: string`
58+
- `callback: (Error, Array<string>>) => ()` - Calls back with an error or a list of topicCIDs that this peer is subscribed to.
59+
60+
If no `callback` is passed, a promise is returned.
61+
62+
#### `pubsub.peers`
63+
64+
> Returns the peers that are subscribed to one topic.
65+
66+
##### `Go` **WIP**
67+
68+
##### `JavaScript` - ipfs.pubsub.peers(topic, callback)
69+
70+
- `topic: string`
71+
- `callback: (Error, Array<string>>) => ()` - Calls back with an error or a list of peer ids subscribed to the `topic`.
72+
73+
If no `callback` is passed, a promise is returned.

CHANGELOG.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,64 @@
1+
<a name="0.23.5"></a>
2+
## [0.23.5](https://github.com/ipfs/interface-ipfs-core/compare/v0.23.4...v0.23.5) (2017-01-17)
3+
4+
5+
6+
<a name="0.23.4"></a>
7+
## [0.23.4](https://github.com/ipfs/interface-ipfs-core/compare/v0.23.3...v0.23.4) (2017-01-17)
8+
9+
10+
### Bug Fixes
11+
12+
* **config:** make promise tests actually test the full promise chain ([416560e](https://github.com/ipfs/interface-ipfs-core/commit/416560e))
13+
14+
15+
16+
<a name="0.23.3"></a>
17+
## [0.23.3](https://github.com/ipfs/interface-ipfs-core/compare/v0.23.2...v0.23.3) (2017-01-16)
18+
19+
20+
### Bug Fixes
21+
22+
* **test:** send/receive 10k messages test ([ad952e2](https://github.com/ipfs/interface-ipfs-core/commit/ad952e2))
23+
24+
25+
26+
<a name="0.23.2"></a>
27+
## [0.23.2](https://github.com/ipfs/interface-ipfs-core/compare/v0.23.1...v0.23.2) (2017-01-11)
28+
29+
30+
### Bug Fixes
31+
32+
* be nodejs 4 compatible ([3e356f0](https://github.com/ipfs/interface-ipfs-core/commit/3e356f0))
33+
34+
35+
36+
<a name="0.23.1"></a>
37+
## [0.23.1](https://github.com/ipfs/interface-ipfs-core/compare/v0.23.0...v0.23.1) (2017-01-11)
38+
39+
40+
### Bug Fixes
41+
42+
* identify needs time to finish ([b76993d](https://github.com/ipfs/interface-ipfs-core/commit/b76993d))
43+
44+
45+
46+
<a name="0.23.0"></a>
47+
# [0.23.0](https://github.com/ipfs/interface-ipfs-core/compare/v0.22.1...v0.23.0) (2016-12-21)
48+
49+
50+
### Bug Fixes
51+
52+
* fix a bunch of issues (i.e: identify race condition) ([d004577](https://github.com/ipfs/interface-ipfs-core/commit/d004577))
53+
54+
55+
### Features
56+
57+
* add first pass of pubsub tests (running in js-ipfs-api) ([74003a7](https://github.com/ipfs/interface-ipfs-core/commit/74003a7))
58+
* new event based API ([1a82890](https://github.com/ipfs/interface-ipfs-core/commit/1a82890))
59+
60+
61+
162
<a name="0.22.1"></a>
263
## [0.22.1](https://github.com/ipfs/interface-ipfs-core/compare/v0.22.0...v0.22.1) (2016-12-10)
364

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "interface-ipfs-core",
3-
"version": "0.22.1",
3+
"version": "0.23.5",
44
"description": "A test suite and interface you can use to implement a IPFS core interface.",
55
"main": "src/index.js",
66
"scripts": {
@@ -27,12 +27,12 @@
2727
"homepage": "https://github.com/ipfs/interface-ipfs-core#readme",
2828
"dependencies": {
2929
"async": "^2.1.4",
30-
"bl": "^1.1.2",
31-
"bs58": "^3.1.0",
30+
"bl": "^1.2.0",
31+
"bs58": "^4.0.0",
3232
"chai": "^3.5.0",
33-
"concat-stream": "^1.5.2",
33+
"concat-stream": "^1.6.0",
3434
"detect-node": "^2.0.3",
35-
"ipfs-block": "^0.5.3",
35+
"ipfs-block": "^0.5.4",
3636
"ipld-dag-pb": "^0.9.3",
3737
"multiaddr": "^2.1.1",
3838
"multihashes": "^0.3.1",
@@ -44,10 +44,12 @@
4444
"contributors": [
4545
"David Dias <[email protected]>",
4646
"Friedel Ziegelmayer <[email protected]>",
47+
"Pedro Teixeira <[email protected]>",
4748
"Richard Littauer <[email protected]>",
4849
"Stephen Whitmore <[email protected]>",
4950
"Victor Bjelkholm <[email protected]>",
5051
"greenkeeperio-bot <[email protected]>",
52+
5153
"nginnever <[email protected]>"
5254
]
5355
}

src/config.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,9 @@ module.exports = (common) => {
158158
describe('.set', () => {
159159
it('set a new key', () => {
160160
return ipfs.config.set('Fruit', 'banana')
161-
.then(() => {
162-
ipfs.config.get('Fruit', (err, fruit) => {
163-
expect(err).to.not.exist
164-
expect(fruit).to.equal('banana')
165-
})
161+
.then(() => ipfs.config.get('Fruit'))
162+
.then((fruit) => {
163+
expect(fruit).to.equal('banana')
166164
})
167165
})
168166
})

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ exports.swarm = require('./swarm')
99
exports.block = require('./block')
1010
exports.dht = require('./dht')
1111
exports.dag = require('./dag')
12+
exports.pubsub = require('./pubsub')

0 commit comments

Comments
 (0)