@@ -6,10 +6,14 @@ const BlockService = require('ipfs-block-service')
6
6
7
7
### ` new BlockService(repo) `
8
8
9
+ - ` repo: Repo `
10
+
9
11
Creates a new block service backed by [ IPFS Repo] [ repo ] ` repo ` for storage.
10
12
11
13
### ` goOnline(bitswap) `
12
14
15
+ - ` bitswap: Bitswap `
16
+
13
17
Add a bitswap instance that communicates with the network to retreive blocks
14
18
that are not in the local store.
15
19
@@ -24,53 +28,40 @@ Remove the bitswap instance and fall back to offline mode.
24
28
25
29
Returns a ` Boolean ` indicating if the block service is online or not.
26
30
27
- ### ` addBlock(block, callback(err)) `
31
+ ### ` put(block, callback) `
32
+
33
+ - ` block: Block `
34
+ - ` callback: Function `
28
35
29
36
Asynchronously adds a block instance to the underlying repo.
30
37
31
- ### ` addBlocks(blocks, callback(err) )`
38
+ ### ` putStream( )`
32
39
33
- Asynchronously adds an array of block instances to the underlying repo.
40
+ Returns a through pull-stream, which ` Block ` s can be written to, and
41
+ that emits the meta data about the written block.
34
42
35
- * Does not guarantee atomicity. *
43
+ ### ` get(multihash [, extension], callback) `
36
44
37
- ### ` getBlock(multihash, callback(err, block)) `
45
+ - ` multihash: Multihash `
46
+ - ` extension: String ` , defaults to 'data'
47
+ - ` callback: Function `
38
48
39
49
Asynchronously returns the block whose content multihash matches ` multihash ` .
40
- Returns an error (` err.code === 'ENOENT' ` ) if the block does not exist.
41
-
42
- If the block could not be found, expect ` err.code ` to be ` 'ENOENT' ` .
43
-
44
- ### ` getBlocks(multihashes, callback(err, blocks)) `
45
-
46
- Asynchronously returns the blocks whose content multihashes match the array
47
- ` multihashes ` .
48
-
49
- ` blocks ` is an object that maps each ` multihash ` to an object of the form
50
-
51
- ``` js
52
- {
53
- err: Error
54
- block: Block
55
- }
56
- ```
57
-
58
- Expect ` blocks[multihash].err.code === 'ENOENT' ` and `blocks[ multihash] .block
59
- === null` if a block did not exist.
60
50
61
- * Does not guarantee atomicity. *
51
+ ### ` getStream(multihash [, extension]) `
62
52
63
- ### ` deleteBlock(multihash, callback(err)) `
53
+ - ` multihash: Multihash `
54
+ - ` extension: String ` , defaults to 'data'
64
55
65
- Asynchronously deletes the block from the store with content multihash matching
66
- ` multihash ` , if it exists.
56
+ Returns a source pull-stream, which emits the requested block.
67
57
68
- ### ` bs.deleteBlocks (multihashes, callback(err) )`
58
+ ### ` delete (multihashes, [, extension], callback)`
69
59
70
- Asynchronously deletes all blocks from the store with content multihashes matching
71
- from the array ` multihashes ` .
60
+ - ` multihashes: Multihash|[]Multihash `
61
+ - ` extension: String ` , defaults to 'data'- ` extension: String ` , defaults to 'data'
62
+ - ` callback: Function `
72
63
73
- * Does not guarantee atomicity. *
64
+ Deletes all blocks referenced by multihashes.
74
65
75
- [ multihash ] : https://github.com/jbenet /js-multihash
66
+ [ multihash ] : https://github.com/multiformats /js-multihash
76
67
[ repo ] : https://github.com/ipfs/specs/tree/master/repo
0 commit comments