Skip to content

Commit

Permalink
Merge pull request #4022 from hermanjunge/feat/block-put-add-cid-codecs
Browse files Browse the repository at this point in the history
Add CID Codecs to block put
  • Loading branch information
whyrusleeping authored Jul 5, 2017
2 parents 6ad24f6 + f512a33 commit 0b481a3
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions core/commands/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (

util "github.com/ipfs/go-ipfs/blocks/blockstore/util"
cmds "github.com/ipfs/go-ipfs/commands"
"gx/ipfs/QmXxGS5QsUxpR3iqL5DjmsYPHR1Yz74siRQ4ChJqWFosMh/go-block-format"

mh "gx/ipfs/QmVGtdTZdTFaLsaj2RwdVG8jcjNNcp1DE914DKZ2kHmXHw/go-multihash"
u "gx/ipfs/QmWbjfz3u6HkAdPh34dgPchGbQjob6LXLhAeCGii2TX69n/go-ipfs-util"
blocks "gx/ipfs/QmXxGS5QsUxpR3iqL5DjmsYPHR1Yz74siRQ4ChJqWFosMh/go-block-format"
cid "gx/ipfs/Qma4RJSuh7mMeJQYCqMbKzekn6EwBo7HEs5AQYjVRMQATB/go-cid"
)

Expand Down Expand Up @@ -149,20 +149,15 @@ It reads from stdin, and <key> is a base58 encoded multihash.
pref.Version = 1

format, _, _ := req.Option("format").String()
switch format {
case "cbor":
pref.Codec = cid.DagCBOR
case "protobuf":
pref.Codec = cid.DagProtobuf
case "raw":
pref.Codec = cid.Raw
case "v0":
pref.Version = 0
pref.Codec = cid.DagProtobuf
default:
formatval, ok := cid.Codecs[format]
if !ok {
res.SetError(fmt.Errorf("unrecognized format: %s", format), cmds.ErrNormal)
return
}
if format == "v0" {
pref.Version = 0
}
pref.Codec = formatval

mhtype, _, _ := req.Option("mhtype").String()
mhtval, ok := mh.Names[mhtype]
Expand Down

0 comments on commit 0b481a3

Please sign in to comment.