mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-03 16:21:04 +00:00
docs: add docs
This commit is contained in:
parent
0c543b7180
commit
1ebf725ac4
@ -249,9 +249,13 @@ class Node extends libp2p {
|
|||||||
|
|
||||||
> PeerInfo instance of the node
|
> 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)`
|
#### `libp2p.dht.put(key, value, callback)`
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ module.exports = (node) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
subscribe: (topic, options, handler, callback) => {
|
subscribe: (topic, options, handler, callback) => {
|
||||||
if (!node.isStarted()) {
|
if (!node.isStarted() && !floodSub.started) {
|
||||||
return setImmediate(() => callback(new Error(NOT_STARTED_YET)))
|
return setImmediate(() => callback(new Error(NOT_STARTED_YET)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,6 +34,10 @@ module.exports = (node) => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
unsubscribe: (topic, handler) => {
|
unsubscribe: (topic, handler) => {
|
||||||
|
if (!node.isStarted() && !floodSub.started) {
|
||||||
|
throw new Error(NOT_STARTED_YET)
|
||||||
|
}
|
||||||
|
|
||||||
floodSub.removeListener(topic, handler)
|
floodSub.removeListener(topic, handler)
|
||||||
|
|
||||||
if (floodSub.listenerCount(topic) === 0) {
|
if (floodSub.listenerCount(topic) === 0) {
|
||||||
@ -42,7 +46,7 @@ module.exports = (node) => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
publish: (topic, data, callback) => {
|
publish: (topic, data, callback) => {
|
||||||
if (!node.isStarted()) {
|
if (!node.isStarted() && !floodSub.started) {
|
||||||
return setImmediate(() => callback(new Error(NOT_STARTED_YET)))
|
return setImmediate(() => callback(new Error(NOT_STARTED_YET)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +60,7 @@ module.exports = (node) => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
ls: (callback) => {
|
ls: (callback) => {
|
||||||
if (!node.isStarted()) {
|
if (!node.isStarted() && !floodSub.started) {
|
||||||
return setImmediate(() => callback(new Error(NOT_STARTED_YET)))
|
return setImmediate(() => callback(new Error(NOT_STARTED_YET)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +70,7 @@ module.exports = (node) => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
peers: (topic, callback) => {
|
peers: (topic, callback) => {
|
||||||
if (!node.isStarted()) {
|
if (!node.isStarted() && !floodSub.started) {
|
||||||
return setImmediate(() => callback(new Error(NOT_STARTED_YET)))
|
return setImmediate(() => callback(new Error(NOT_STARTED_YET)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user