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 |
58
82
59
83
**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
84
61
-
**Returns**
85
+
### Returns
62
86
63
87
| Type | Description |
64
88
| -------- | -------- |
65
89
|`Promise<Block>`| A [Block][block] type object, containing both the data and the hash of the block |
| timeout |`Number`|`undefined`| A timeout in ms |
142
+
| signal |[AbortSignal][]|`undefined`| Can be used to cancel any long running requests started as a result of this call |
116
143
117
-
**Returns**
144
+
### Returns
118
145
119
146
| Type | Description |
120
147
| -------- | -------- |
@@ -131,7 +158,7 @@ Each object yielded is of the form:
131
158
132
159
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
160
134
-
**Example:**
161
+
### Example
135
162
136
163
```JavaScript
137
164
forawait (constresultofipfs.block.rm(cid)) {
@@ -141,19 +168,26 @@ for await (const result of ipfs.block.rm(cid)) {
141
168
142
169
A great source of [examples][] can be found in the tests for this API.
143
170
144
-
#### `block.stat`
171
+
##`ipfs.block.stat(cid, [options])`
145
172
146
173
> Print information of a raw IPFS block.
147
174
148
-
##### `ipfs.block.stat(cid)`
175
+
### Parameters
176
+
177
+
| Name | Type | Description |
178
+
| ---- | ---- | ----------- |
179
+
| cid | A [CID][] or Array of [CID][]s | The stats of the passed CID will be returned |
180
+
181
+
### Options
149
182
150
-
`cid` is a [cid][cid]which can be passed as:
183
+
An optional object which may have the following keys:
151
184
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
185
+
| Name | Type | Default | Description |
186
+
| ---- | ---- | ------- | ----------- |
187
+
| timeout |`Number`|`undefined`| A timeout in ms |
188
+
| signal |[AbortSignal][]|`undefined`| Can be used to cancel any long running requests started as a result of this call |
155
189
156
-
**Returns**
190
+
### Returns
157
191
158
192
| Type | Description |
159
193
| -------- | -------- |
@@ -168,7 +202,7 @@ the returned object has the following keys:
0 commit comments