1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-29 01:12:24 +08:00

ipfs block put: Add CID Codecs to "ipfs block put"

Adding codecs found in
Use the codec map implemented in https://github.com/ipfs/go-cid/pull/26

License: MIT
Signed-off-by: Herman Junge <chpdg42@gmail.com>
This commit is contained in:
Herman Junge
2017-06-28 22:09:00 -04:00
parent ba9435d850
commit f512a33998

View File

@ -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"
)
@ -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]