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

Commit 35e2353

Browse files
committed
feat: update block spec to support CID
1 parent 00fe0f7 commit 35e2353

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

API/block/README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ block API
77
88
##### `Go` **WIP**
99

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

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

14-
- Buffer, the raw Buffer of the multihash
14+
- Buffer, the raw Buffer of the cid
15+
- CID, a CID instance
1516
- String, the base58 encoded version of the multihash
1617

1718
`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.
1819

1920
```js
20-
ipfs.block.get(multihash, function (err, block) {
21+
ipfs.block.get(cid, function (err, block) {
2122
if (err) {
2223
throw err
2324
}
@@ -38,13 +39,19 @@ If no `callback` is passed, a promise is returned.
3839
3940
##### `Go` **WIP**
4041

41-
##### `JavaScript` - ipfs.block.put(block, [callback])
42+
##### `JavaScript` - ipfs.block.put(block, cid, [callback])
4243

4344
Where `block` can be:
4445

4546
- `Buffer` - the raw bytes of the Block
4647
- [`Block`][block] instance
4748

49+
`cid` is a [cid][cid] which can be passed as:
50+
51+
- Buffer, the raw Buffer of the cid
52+
- CID, a CID instance
53+
- String, the base58 encoded version of the multihash
54+
4855
`callback` has the signature `function (err, block) {}`, 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.
4956

5057
If no `callback` is passed, a promise is returned.
@@ -55,18 +62,19 @@ If no `callback` is passed, a promise is returned.
5562
5663
##### `Go` **WIP**
5764

58-
##### `JavaScript` - ipfs.block.stat(multihash, [callback])
65+
##### `JavaScript` - ipfs.block.stat(cid, [callback])
5966

60-
`multihash` is a [multihash][multihash] which can be passed as:
67+
`cid` is a [cid][cid] which can be passed as:
6168

6269
- `Buffer`, the raw Buffer of the multihash (or of and encoded version)
6370
- `String`, the toString version of the multihash (or of an encoded version)
71+
- CID, a CID instance
6472

6573
`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:`
6674

6775
```JavaScript
6876
{
69-
key: 'QmPTkMuuL6PD8L2SwTwbcs1NPg14U8mRzerB1ZrrBrkSDD',
77+
cid: 'QmPTkMuuL6PD8L2SwTwbcs1NPg14U8mRzerB1ZrrBrkSDD',
7078
size: 10
7179
}
7280
```

src/block.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ module.exports = (common) => {
3838
})
3939
})
4040

41-
after((done) => {
42-
common.teardown(done)
43-
})
41+
after((done) => common.teardown(done))
4442

4543
describe('callback API', () => {
4644
it('.put a buffer', (done) => {
@@ -123,7 +121,6 @@ module.exports = (common) => {
123121
it.skip('block.rm', (done) => {}) // TODO once block.rm is shipped in go-ipfs
124122
})
125123

126-
describe('promise API', () => {
127-
})
124+
describe('promise API', () => {})
128125
})
129126
}

0 commit comments

Comments
 (0)