Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CID Codecs to block put #4022

Merged
merged 1 commit into from Jul 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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