lotus/chain/vm/cbor_gen.go

177 lines
3.3 KiB
Go
Raw Normal View History

2022-03-13 21:24:13 +00:00
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
package vm
import (
"fmt"
"io"
"math"
"sort"
cid "github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors"
2022-06-14 15:00:51 +00:00
types "github.com/filecoin-project/lotus/chain/types"
2022-03-13 21:24:13 +00:00
)
var _ = xerrors.Errorf
var _ = cid.Undef
var _ = math.E
var _ = sort.Sort
var lengthBufFvmExecutionTrace = []byte{132}
func (t *FvmExecutionTrace) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
2022-05-23 19:11:46 +00:00
cw := cbg.NewCborWriter(w)
if _, err := cw.Write(lengthBufFvmExecutionTrace); err != nil {
2022-03-13 21:24:13 +00:00
return err
}
// t.Msg (types.Message) (struct)
2022-05-23 19:11:46 +00:00
if err := t.Msg.MarshalCBOR(cw); err != nil {
2022-03-13 21:24:13 +00:00
return err
}
// t.MsgRct (types.MessageReceipt) (struct)
2022-05-23 19:11:46 +00:00
if err := t.MsgRct.MarshalCBOR(cw); err != nil {
2022-03-13 21:24:13 +00:00
return err
}
// t.Error (string) (string)
if len(t.Error) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.Error was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Error))); err != nil {
2022-03-13 21:24:13 +00:00
return err
}
if _, err := io.WriteString(w, string(t.Error)); err != nil {
return err
}
// t.Subcalls ([]vm.FvmExecutionTrace) (slice)
if len(t.Subcalls) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Subcalls was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Subcalls))); err != nil {
2022-03-13 21:24:13 +00:00
return err
}
for _, v := range t.Subcalls {
2022-05-23 19:11:46 +00:00
if err := v.MarshalCBOR(cw); err != nil {
2022-03-13 21:24:13 +00:00
return err
}
}
return nil
}
2022-05-23 19:11:46 +00:00
func (t *FvmExecutionTrace) UnmarshalCBOR(r io.Reader) (err error) {
2022-03-13 21:24:13 +00:00
*t = FvmExecutionTrace{}
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2022-03-13 21:24:13 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2022-03-13 21:24:13 +00:00
if err != nil {
return err
}
2022-05-23 19:11:46 +00:00
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
2022-03-13 21:24:13 +00:00
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 4 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.Msg (types.Message) (struct)
{
2022-05-23 19:11:46 +00:00
b, err := cr.ReadByte()
2022-03-13 21:24:13 +00:00
if err != nil {
return err
}
if b != cbg.CborNull[0] {
2022-05-23 19:11:46 +00:00
if err := cr.UnreadByte(); err != nil {
2022-03-13 21:24:13 +00:00
return err
}
t.Msg = new(types.Message)
2022-05-23 19:11:46 +00:00
if err := t.Msg.UnmarshalCBOR(cr); err != nil {
2022-03-13 21:24:13 +00:00
return xerrors.Errorf("unmarshaling t.Msg pointer: %w", err)
}
}
}
// t.MsgRct (types.MessageReceipt) (struct)
{
2022-05-23 19:11:46 +00:00
b, err := cr.ReadByte()
2022-03-13 21:24:13 +00:00
if err != nil {
return err
}
if b != cbg.CborNull[0] {
2022-05-23 19:11:46 +00:00
if err := cr.UnreadByte(); err != nil {
2022-03-13 21:24:13 +00:00
return err
}
t.MsgRct = new(types.MessageReceipt)
2022-05-23 19:11:46 +00:00
if err := t.MsgRct.UnmarshalCBOR(cr); err != nil {
2022-03-13 21:24:13 +00:00
return xerrors.Errorf("unmarshaling t.MsgRct pointer: %w", err)
}
}
}
// t.Error (string) (string)
{
2022-05-23 19:11:46 +00:00
sval, err := cbg.ReadString(cr)
2022-03-13 21:24:13 +00:00
if err != nil {
return err
}
t.Error = string(sval)
}
// t.Subcalls ([]vm.FvmExecutionTrace) (slice)
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
2022-03-13 21:24:13 +00:00
if err != nil {
return err
}
if extra > cbg.MaxLength {
return fmt.Errorf("t.Subcalls: array too large (%d)", extra)
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.Subcalls = make([]FvmExecutionTrace, extra)
}
for i := 0; i < int(extra); i++ {
var v FvmExecutionTrace
2022-05-23 19:11:46 +00:00
if err := v.UnmarshalCBOR(cr); err != nil {
2022-03-13 21:24:13 +00:00
return err
}
t.Subcalls[i] = v
}
return nil
}