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

Commit 4333c2e

Browse files
committed
fix(block spec): apply CR
1 parent 980bb12 commit 4333c2e

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

API/block/README.md

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,43 @@ block API
77
88
##### `Go` **WIP**
99

10-
##### `JavaScript` - ipfs.block.get(multihash, [callback])
10+
##### `JavaScript` - ipfs.block.get(multihash, [options, callback])
1111

12-
`multihash` is a [multihash][] which can be passed as
12+
`multihash` is a [multihash][multihash] which can be passed as:
1313

1414
- Buffer, the raw Buffer of the multihash
1515
- String, the base58 encoded version of the multihash
1616

17-
`callback` must follow `function (err, block) {}` signature, where `err` is an error if the operation was not successful and `block` is a [Block][].
18-
17+
`callback` must follow `function (err, block) {}` signature, where `err` is an error if the operation was not successful and `block` is a [Block][block] type object, containing both the data and the hash of the block.
1918

2019
```js
21-
ipfs.block.get(multihash, function (err, data) {
22-
// data is the raw data contained in a block
20+
ipfs.block.get(multihash, function (err, block) {
21+
if (err) {
22+
throw err
23+
}
24+
console.log(block.key, block.data)
2325
})
2426
```
2527

2628
If no `callback` is passed, a promise is returned.
2729

28-
29-
30-
3130
#### `put`
3231

3332
> Stores input as an IPFS block.
3433
3534
##### `Go` **WIP**
3635

37-
##### `JavaScript` - ipfs.block.put(data, [callback])
36+
##### `JavaScript` - ipfs.block.put(block, [callback])
3837

39-
Where `data` can be a
38+
Where `block` can be:
4039

41-
- Buffer, requiring that the encoding is specified on the options. if no
42-
encoding is specified, Buffer is treated as the Data field
43-
- [Block][] instance
40+
- `Buffer` - the raw bytes of the Block
41+
- [`Block`][block] instance
4442

45-
`callback` has the signature `function (err, block) {}`, where `err` is an error
46-
if the operation was not successful. and `block` is a [Block][].
43+
`callback` has the signature `function (err) {}`, where `err` is an error if the operation was not successful.
4744

4845
If no `callback` is passed, a promise is returned.
4946

50-
51-
52-
53-
5447
#### `stat`
5548

5649
> Print information of a raw IPFS block.
@@ -59,14 +52,12 @@ If no `callback` is passed, a promise is returned.
5952

6053
##### `JavaScript` - ipfs.block.stat(multihash, [callback])
6154

62-
`multihash` is a [multihash][] which can be passed as:
55+
`multihash` is a [multihash][multihash] which can be passed as:
6356

64-
- Buffer, the raw Buffer of the multihash (or of and encoded version)
65-
- String, the toString version of the multihash (or of an encoded version)
57+
- `Buffer`, the raw Buffer of the multihash (or of and encoded version)
58+
- `String`, the toString version of the multihash (or of an encoded version)
6659

67-
`callback` must follow the signature `function (err, stats) {}`, where `err` is
68-
an error if the operation was not successful and `stats` is an object with
69-
the format
60+
`callback` must follow the signature `function (err, stats) {}`, where `err` is an error if the operation was not successful and `stats` is an object with the format:`
7061

7162
```JavaScript
7263
{
@@ -75,4 +66,7 @@ the format
7566
}
7667
```
7768

78-
If no `callback` is passed, a promise is returned.
69+
If no `callback` is passed, a promise is returned.
70+
71+
[block](https://github.com/ipfs/js-ipfs-block)
72+
[multihash](https://github.com/multiformats/multihash)

0 commit comments

Comments
 (0)