@@ -17,8 +17,7 @@ IPFS Block Service JavaScript Implementation
17
17
18
18
** BlockService** - A BlockService is a content-addressable store for blocks,
19
19
providing an API for adding, deleting, and retrieving blocks. A BlockService is
20
- backed by an [ IPFS Repo] [ repo ] as its datastore for blocks, and uses an [ IPFS
21
- Exchange] [ bitswap ] implementation to fetch blocks from the network.
20
+ backed by an [ IPFS Repo] [ repo ] as its datastore for blocks, and uses [ Bitswap] [ bitswap ] to fetch blocks from the network.
22
21
23
22
``` markdown
24
23
┌────────────────────┐
@@ -27,9 +26,9 @@ Exchange][bitswap] implementation to fetch blocks from the network.
27
26
│
28
27
┌─────┴─────┐
29
28
▼ ▼
30
- ┌─────────┐ ┌──────── ┐
31
- │IPFS Repo│ │Exchange │
32
- └─────────┘ └──────── ┘
29
+ ┌─────────┐ ┌───────┐
30
+ │IPFS Repo│ |Bitswap │
31
+ └─────────┘ └───────┘
33
32
```
34
33
35
34
## Example
@@ -99,7 +98,7 @@ var BlockService = require('ipfs-block-service')
99
98
100
99
### Browser: ` <script> ` Tag
101
100
102
- Loading this module through a script tag will make the ` Unixfs ` obj available in
101
+ Loading this module through a script tag will make the ` IpfsBlockService ` obj available in
103
102
the global namespace.
104
103
105
104
``` html
@@ -108,71 +107,11 @@ the global namespace.
108
107
<script src =" https://npmcdn.com/ipfs-block-service/dist/index.js" ></script >
109
108
```
110
109
111
- ## API
112
-
113
- ``` js
114
- const BlockService = require (' ipfs-block-service' )
115
- ```
116
-
117
- ### var bs = new BlockService(repo[ , exchange] )
118
-
119
- Creates a new block service backed by [ IPFS Repo] [ repo ] ` repo ` for storage, and
120
- [ IPFS Exchange] [ bitswap ] for retrieving blocks from the network. Providing an
121
- ` exchange ` is optional.
122
-
123
- #### bs.addBlock(block, callback(err))
124
-
125
- Asynchronously adds a block instance to the underlying repo.
126
-
127
- #### bs.addBlocks(blocks, callback(err))
128
-
129
- Asynchronously adds an array of block instances to the underlying repo.
130
-
131
- * Does not guarantee atomicity.*
132
-
133
- #### bs.getBlock(multihash, callback(err, block))
134
-
135
- Asynchronously returns the block whose content multihash matches ` multihash ` .
136
- Returns an error (` err.code === 'ENOENT' ` ) if the block does not exist.
137
-
138
- If the block could not be found, expect ` err.code ` to be ` 'ENOENT' ` .
139
-
140
- #### bs.getBlocks(multihashes, callback(err, blocks))
141
-
142
- Asynchronously returns the blocks whose content multihashes match the array
143
- ` multihashes ` .
144
-
145
- ` blocks ` is an object that maps each ` multihash ` to an object of the form
146
-
147
- ``` js
148
- {
149
- err: Error
150
- block: Block
151
- }
152
- ```
153
-
154
- Expect ` blocks[multihash].err.code === 'ENOENT' ` and `blocks[ multihash] .block
155
- === null` if a block did not exist.
156
-
157
- * Does not guarantee atomicity.*
158
-
159
- #### bs.deleteBlock(multihash, callback(err))
160
-
161
- Asynchronously deletes the block from the store with content multihash matching
162
- ` multihash ` , if it exists.
163
-
164
- #### bs.deleteBlocks(multihashes, callback(err))
165
-
166
- Asynchronously deletes all blocks from the store with content multihashes matching
167
- from the array ` multihashes ` .
168
-
169
- * Does not guarantee atomicity.*
110
+ You can find the [ API documentation here] ( API.md )
170
111
171
112
## License
172
113
173
114
MIT
174
115
175
116
[ ipfs ] : https://ipfs.io
176
- [ repo ] : https://github.com/ipfs/specs/tree/master/repo
177
117
[ bitswap ] : https://github.com/ipfs/specs/tree/master/bitswap
178
- [ multihash ] : https://github.com/jbenet/js-multihash
0 commit comments