Merge pull request #1389 from filecoin-project/feat/chain-get-raw-type

cli: add cbor-hex type to chain get
This commit is contained in:
Whyrusleeping 2020-03-11 00:10:57 -07:00 committed by GitHub
commit fb91ea2470

View File

@ -451,6 +451,8 @@ var chainGetCmd = &cli.Command{
var cbu cbg.CBORUnmarshaler
switch t {
case "raw":
cbu = nil
case "block":
cbu = new(types.BlockHeader)
case "message":
@ -476,6 +478,11 @@ var chainGetCmd = &cli.Command{
return err
}
if cbu == nil {
fmt.Printf("%x", raw)
return nil
}
if err := cbu.UnmarshalCBOR(bytes.NewReader(raw)); err != nil {
return fmt.Errorf("failed to unmarshal as %q", t)
}