docs: add docs

This commit is contained in:
David Dias 2018-02-15 19:39:06 +01:00
parent 0c543b7180
commit 1ebf725ac4
2 changed files with 13 additions and 5 deletions

View File

@ -249,9 +249,13 @@ class Node extends libp2p {
> PeerInfo instance of the node
#### `libp2p.pubsub`
> Same API as IPFS PubSub, defined in the [CORE API Spec](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PUBSUB.md). Just replace `ipfs` by `libp2p` and you are golden.
---------------------
`DHT methods exposed`
`DHT methods also exposed for the time being`
#### `libp2p.dht.put(key, value, callback)`

View File

@ -11,7 +11,7 @@ module.exports = (node) => {
return {
subscribe: (topic, options, handler, callback) => {
if (!node.isStarted()) {
if (!node.isStarted() && !floodSub.started) {
return setImmediate(() => callback(new Error(NOT_STARTED_YET)))
}
@ -34,6 +34,10 @@ module.exports = (node) => {
},
unsubscribe: (topic, handler) => {
if (!node.isStarted() && !floodSub.started) {
throw new Error(NOT_STARTED_YET)
}
floodSub.removeListener(topic, handler)
if (floodSub.listenerCount(topic) === 0) {
@ -42,7 +46,7 @@ module.exports = (node) => {
},
publish: (topic, data, callback) => {
if (!node.isStarted()) {
if (!node.isStarted() && !floodSub.started) {
return setImmediate(() => callback(new Error(NOT_STARTED_YET)))
}
@ -56,7 +60,7 @@ module.exports = (node) => {
},
ls: (callback) => {
if (!node.isStarted()) {
if (!node.isStarted() && !floodSub.started) {
return setImmediate(() => callback(new Error(NOT_STARTED_YET)))
}
@ -66,7 +70,7 @@ module.exports = (node) => {
},
peers: (topic, callback) => {
if (!node.isStarted()) {
if (!node.isStarted() && !floodSub.started) {
return setImmediate(() => callback(new Error(NOT_STARTED_YET)))
}