kubo/core/coredag/cbor.go
Steven Allen 85acad9a01 gx update go-log, sys, go-crypto
* go-log
* sys
* go-crypto

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2018-06-08 22:36:24 -07:00

33 lines
679 B
Go

package coredag
import (
"io"
"io/ioutil"
ipldcbor "gx/ipfs/QmSF1Ksgn5d7JCTBt4e1yp4wzs6tpYyweCZ4PcDYp3tNeK/go-ipld-cbor"
ipld "gx/ipfs/QmWi2BYBL5gJ3CiAiQchg6rn1A8iBsrWy51EYxvHVjFvLb/go-ipld-format"
)
func cborJSONParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
nd, err := ipldcbor.FromJson(r, mhType, mhLen)
if err != nil {
return nil, err
}
return []ipld.Node{nd}, nil
}
func cborRawParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
data, err := ioutil.ReadAll(r)
if err != nil {
return nil, err
}
nd, err := ipldcbor.Decode(data, mhType, mhLen)
if err != nil {
return nil, err
}
return []ipld.Node{nd}, nil
}