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

Commit e9c15c2

Browse files
committed
Merge pull request #15 from noffle/blocks
draft api docs for blocks
2 parents c2093aa + afc2a02 commit e9c15c2

File tree

1 file changed

+73
-4
lines changed

1 file changed

+73
-4
lines changed

README.md

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,78 @@ test.all(common)
5454

5555
A valid (read: that follows this interface) IPFS core implementation, must expose the following API.
5656

57+
## Block
58+
59+
### `block.put`
60+
61+
> Create a new IPFS Block.
62+
63+
##### `Go` **WIP**
64+
65+
##### `JavaScript` - ipfs.block.put(data, [callback])
66+
67+
Where `data` can be a
68+
69+
- Buffer, requiring that the encoding is specified on the options. If no
70+
encoding is specified, Buffer is treated as the Data field
71+
- [Block][] instance
72+
73+
`callback` has the signature `function (err, block) {}`, where `err` is an error
74+
if the operation was not successful. and `block` is a [Block][].
75+
76+
77+
78+
79+
### `block.get`
80+
81+
> Retrieve an IPFS Block from the underlying Block Store by its mulithash.
82+
83+
##### `Go` **WIP**
84+
85+
##### `JavaScript` - ipfs.block.get(multihash, [callback])
86+
87+
`multihash` is a [multihash][] which can be passed as a
88+
89+
- Buffer, the raw Buffer of the multihash (or of and encoded version)
90+
- String, the toString version of the multihash (or of an encoded version)
91+
92+
`callback` must follow the signature `function (err, node) {}`, where `err` is
93+
an error if the operation was not successful and `block` is a [Block][].
94+
95+
If no `callback` is passed, a promise is returned.
96+
97+
98+
99+
100+
### `block.stat`
101+
102+
> Returns various stats of an IPFS Block
103+
104+
##### `Go` **WIP**
105+
106+
##### `JavaScript` - ipfs.block.stat(multihash, [options, callback])
107+
108+
`multihash` is a [multihash][] which can be passed as:
109+
110+
- Buffer, the raw Buffer of the multihash (or of and encoded version)
111+
- String, the toString version of the multihash (or of an encoded version)
112+
113+
`callback` must follow the signature `function (err, stats) {}`, where `err` is
114+
an error if the operation was not successful and `stats` is an object with
115+
the format
116+
117+
```JavaScript
118+
{
119+
Key: 'QmPTkMuuL6PD8L2SwTwbcs1NPg14U8mRzerB1ZrrBrkSDD',
120+
Size: 10
121+
}
122+
```
123+
124+
If no `callback` is passed, a promise is returned.
125+
126+
127+
128+
57129
## Object
58130

59131
### `object.new`
@@ -119,10 +191,6 @@ If no `callback` is passed, a promise is returned.
119191

120192
If no `callback` is passed, a promise is returned.
121193

122-
### `object.data`
123-
124-
> Returns the Data field of an object
125-
126194
##### `Go` **WIP**
127195

128196
##### `JavaScript` - ipfs.object.data(multihash, [options, callback])
@@ -309,5 +377,6 @@ If no `callback` is passed, a promise is returned.
309377
If no `callback` is passed, a promise is returned.
310378

311379

380+
[Block]: https://github.com/ipfs/js-ipfs-block
312381
[DAGNode]: https://github.com/vijayee/js-ipfs-merkle-dag
313382
[multihash]: http://github.com/jbenet/multihash

0 commit comments

Comments
 (0)