You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Passes a [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
to every API call which emits a `abort` event when the caller is no longer
interested in the result of the operation.
Lower level code that creates resources or has other long-term effects should tear
down those resources early if the `abort` event is received.
Adds support for `timeout` options to every API call that will emit an `abort` event
on the passed signal and throw a Timeout error.
Finally `abort` events are triggered if the current request arrived via the HTTP API
and the request was aborted from the client - that is, a `disconnect` event is fired by Hapi.
- Updates the core-api docs to add these new options.
- Refactors HTTP API to replace custom args parsing with Joi
- Tests all HTTP API endpoints
- Adds pin support to `ipfs.block.put`- fixes#3015
| timeout |`Number`|`undefined`| A timeout in ms |
81
+
| signal |[AbortSignal][]|`undefined`| Can be used to cancel any long running requests started as a result of this call |
56
82
57
-
if no options are passed, it defaults to `{ format: 'dag-pb', mhtype: 'sha2-256', version: 0 }`
83
+
if no options are passed, it defaults to `{ format: 'dag-pb', mhtype: 'sha2-256', version: 0, pin: false }`
58
84
59
85
**Note:** If you pass a [`Block`][block] instance as the block parameter, you don't need to pass options, as the block instance will carry the CID value as a property.
60
86
61
-
**Returns**
87
+
### Returns
62
88
63
89
| Type | Description |
64
90
| -------- | -------- |
65
91
|`Promise<Block>`| A [Block][block] type object, containing both the data and the hash of the block |
| timeout |`Number`|`undefined`| A timeout in ms |
144
+
| signal |[AbortSignal][]|`undefined`| Can be used to cancel any long running requests started as a result of this call |
116
145
117
-
**Returns**
146
+
### Returns
118
147
119
148
| Type | Description |
120
149
| -------- | -------- |
@@ -131,7 +160,7 @@ Each object yielded is of the form:
131
160
132
161
Note: If an error string is present for a given object, the block with that hash was not removed and the string will contain the reason why, for example if the block was pinned.
133
162
134
-
**Example:**
163
+
### Example
135
164
136
165
```JavaScript
137
166
forawait (constresultofipfs.block.rm(cid)) {
@@ -141,19 +170,26 @@ for await (const result of ipfs.block.rm(cid)) {
141
170
142
171
A great source of [examples][] can be found in the tests for this API.
143
172
144
-
#### `block.stat`
173
+
##`ipfs.block.stat(cid, [options])`
145
174
146
175
> Print information of a raw IPFS block.
147
176
148
-
##### `ipfs.block.stat(cid)`
177
+
### Parameters
178
+
179
+
| Name | Type | Description |
180
+
| ---- | ---- | ----------- |
181
+
| cid | A [CID][] or Array of [CID][]s | The stats of the passed CID will be returned |
182
+
183
+
### Options
149
184
150
-
`cid` is a [cid][cid]which can be passed as:
185
+
An optional object which may have the following keys:
151
186
152
-
-`Buffer`, the raw Buffer of the multihash (or of and encoded version)
153
-
-`String`, the toString version of the multihash (or of an encoded version)
154
-
- CID, a CID instance
187
+
| Name | Type | Default | Description |
188
+
| ---- | ---- | ------- | ----------- |
189
+
| timeout |`Number`|`undefined`| A timeout in ms |
190
+
| signal |[AbortSignal][]|`undefined`| Can be used to cancel any long running requests started as a result of this call |
155
191
156
-
**Returns**
192
+
### Returns
157
193
158
194
| Type | Description |
159
195
| -------- | -------- |
@@ -168,7 +204,7 @@ the returned object has the following keys:
0 commit comments