@@ -9,9 +9,14 @@ const CID = require('cids')
9
9
module . exports = ( send ) => {
10
10
return {
11
11
/**
12
+ * Get a raw IPFS block
13
+ *
12
14
* @alias block.get
13
15
* @method
14
- * @returns {Promise|undefined }
16
+ * @param {CID|string } args - the multihash or CID of the block.
17
+ * @param {Object } [opts={}]
18
+ * @param {function(Error, Block) } [callback]
19
+ * @returns {Promise<Block>|undefined }
15
20
* @memberof Api#
16
21
*/
17
22
get : promisify ( ( args , opts , callback ) => {
@@ -46,15 +51,20 @@ module.exports = (send) => {
46
51
} ) ,
47
52
48
53
/**
54
+ * Print information of a raw IPFS block.
55
+ *
49
56
* @alias block.stat
50
57
* @method
51
- * @returns {Promise|undefined }
58
+ * @param {CID|string } key - the `base58` multihash or CID of the block.
59
+ * @param {Object } [opts={}]
60
+ * @param {function(Error, {key: string, size: string}) } [callback]
61
+ * @returns {Promise<{key: string, size: string}>|undefined }
52
62
* @memberof Api#
53
63
*/
54
- stat : promisify ( ( args , opts , callback ) => {
64
+ stat : promisify ( ( key , opts , callback ) => {
55
65
// TODO this needs to be adjusted with the new go-ipfs http-api
56
- if ( args && CID . isCID ( args ) ) {
57
- args = multihash . toB58String ( args . multihash )
66
+ if ( key && CID . isCID ( key ) ) {
67
+ key = multihash . toB58String ( key . multihash )
58
68
}
59
69
60
70
if ( typeof ( opts ) === 'function' ) {
@@ -63,7 +73,7 @@ module.exports = (send) => {
63
73
}
64
74
return send ( {
65
75
path : 'block/stat' ,
66
- args : args ,
76
+ args : key ,
67
77
qs : opts
68
78
} , ( err , stats ) => {
69
79
if ( err ) {
@@ -77,9 +87,15 @@ module.exports = (send) => {
77
87
} ) ,
78
88
79
89
/**
90
+ * Store input as an IPFS block.
91
+ *
80
92
* @alias block.put
81
93
* @method
82
- * @returns {Promise|undefined }
94
+ * @param {Object } block - The block to create.
95
+ * @param {Buffer } block.data - The data to be stored as an IPFS block.
96
+ * @param {CID } [cid]
97
+ * @param {function(Error, Block) } [callback]
98
+ * @returns {Promise<Block>|undefined }
83
99
* @memberof Api#
84
100
*/
85
101
put : promisify ( ( block , cid , callback ) => {
0 commit comments