Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit a8f78cd

Browse files
author
Alan Shaw
committed
fix: remove duplicated logic
License: MIT Signed-off-by: Alan Shaw <[email protected]>
1 parent d44421a commit a8f78cd

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

src/cli/commands/block/put.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,19 @@
11
'use strict'
22

3-
const CID = require('cids')
4-
const multihashing = require('multihashing-async')
53
const bl = require('bl')
64
const fs = require('fs')
7-
const Block = require('ipfs-block')
8-
const waterfall = require('async/waterfall')
95
const multibase = require('multibase')
106
const { print } = require('../../utils')
117
const { cidToString } = require('../../../utils/cid')
128

139
function addBlock (data, opts) {
1410
const ipfs = opts.ipfs
15-
let cid
1611

17-
waterfall([
18-
(cb) => multihashing(data, opts.mhtype || 'sha2-256', cb),
19-
(multihash, cb) => {
20-
if (opts.format !== 'dag-pb' || opts.version !== 0) {
21-
cid = new CID(1, opts.format || 'dag-pb', multihash)
22-
} else {
23-
cid = new CID(0, 'dag-pb', multihash)
24-
}
25-
26-
ipfs.block.put(new Block(data, cid), cb)
27-
}
28-
], (err) => {
12+
ipfs.block.put(data, (err, block) => {
2913
if (err) {
3014
throw err
3115
}
32-
print(cidToString(cid, opts.cidBase))
16+
print(cidToString(block.cid, opts.cidBase))
3317
})
3418
}
3519

0 commit comments

Comments
 (0)