mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-07 01:08:08 +08:00
* yamux: fix memory leak. * refmt: obey the "empty" tag. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
33 lines
679 B
Go
33 lines
679 B
Go
package coredag
|
|
|
|
import (
|
|
"io"
|
|
"io/ioutil"
|
|
|
|
ipldcbor "gx/ipfs/Qma8k32hzB25pgmdTPQr2DCa2DT2v7yCyGadMiYVKF1pyH/go-ipld-cbor"
|
|
ipld "gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/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
|
|
}
|