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

Commit 1e86e7f

Browse files
committed
docs: ipns over pubsub
1 parent 1e02740 commit 1e86e7f

File tree

1 file changed

+92
-2
lines changed

1 file changed

+92
-2
lines changed

SPEC/NAME.md

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
* [name.publish](#namepublish)
44
* [name.resolve](#nameresolve)
5+
* [name.pubsub.cancel](#namepubsubcancel)
6+
* [name.pubsub.state](#namepubsubstate)
7+
* [name.pubsub.subs](#namepubsubsubs)
58

69
#### `name.publish`
710

@@ -76,6 +79,8 @@ This way, you can republish a new version of your website under the same address
7679

7780
`callback` must follow `function (err, name) {}` signature, where `err` is an error if the operation was not successful. `name` is a string that contains the IPFS hash.
7881

82+
`callback` must follow `function (err, result) {}` signature, where `err` is an error if the operation was not successful. `result` is an object that contains the resulting path, such as:
83+
7984
If no `callback` is passed, a promise is returned.
8085

8186
**Example:**
@@ -84,8 +89,93 @@ If no `callback` is passed, a promise is returned.
8489
// The IPNS address you want to resolve.
8590
const addr = '/ipns/ipfs.io'
8691

87-
ipfs.name.resolve(addr, function (err, name) {
88-
console.log(name)
92+
ipfs.name.resolve(addr, function (err, result) {
93+
console.log(result.path)
8994
// /ipfs/QmQrX8hka2BtNHa8N8arAq16TCVx5qHcb46c5yPewRycLm
9095
})
9196
```
97+
98+
#### `name.pubsub.cancel`
99+
100+
> Cancel a name subscription.
101+
102+
##### `Go` **WIP**
103+
104+
##### `JavaScript` - ipfs.name.pubsub.cancel(arg, [callback])
105+
106+
`arg` is the name of the subscription to cancel.
107+
108+
`callback` must follow `function (err, result) {}` signature, where `err` is an error if the operation was not successful. `result` is an object that contains the result of the operation, such as:
109+
110+
```JavaScript
111+
{
112+
canceled: true
113+
}
114+
```
115+
116+
If no `callback` is passed, a promise is returned.
117+
118+
**Example:**
119+
120+
```JavaScript
121+
const name = 'QmQrX8hka2BtNHa8N8arAq16TCVx5qHcb46c5yPewRycLm'
122+
123+
ipfs.name.pubsub.cancel(name, function (err, result) {
124+
console.log(result.canceled)
125+
// true
126+
})
127+
```
128+
129+
#### `name.pubsub.state`
130+
131+
> Query the state of IPNS pubsub.
132+
133+
##### `Go` **WIP**
134+
135+
##### `JavaScript` - ipfs.name.pubsub.state([callback])
136+
137+
`callback` must follow `function (err, result) {}` signature, where `err` is an error if the operation was not successful. `result` is an object that contains the result of the operation, such as:
138+
139+
```JavaScript
140+
{
141+
enabled: true
142+
}
143+
```
144+
145+
If no `callback` is passed, a promise is returned.
146+
147+
**Example:**
148+
149+
```JavaScript
150+
ipfs.name.pubsub.state(function (err, result) {
151+
console.log(result.enabled)
152+
// true
153+
})
154+
```
155+
156+
#### `name.pubsub.subs`
157+
158+
> Show current name subscriptions.
159+
160+
##### `Go` **WIP**
161+
162+
##### `JavaScript` - ipfs.name.pubsub.subs([callback])
163+
164+
`callback` must follow `function (err, result) {}` signature, where `err` is an error if the operation was not successful. `result` is an object that contains the result of the operation, such as:
165+
166+
```JavaScript
167+
{
168+
strings: ['QmQrX8hka2BtNHa8N8arAq16TCVx5qHcb46c5yPewRycLm']
169+
}
170+
```
171+
172+
If no `callback` is passed, a promise is returned.
173+
174+
**Example:**
175+
176+
```JavaScript
177+
ipfs.name.pubsub.subs(function (err, result) {
178+
console.log(result.strings)
179+
// ['QmQrX8hka2BtNHa8N8arAq16TCVx5qHcb46c5yPewRycLm']
180+
})
181+
```

0 commit comments

Comments
 (0)