lotus/chain/vm/cbor_gen.go

392 lines
7.7 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-09-09 20:42:55 +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
2022-09-09 20:26:55 +00:00
var lengthBufFvmExecutionTrace = []byte{133}
2022-03-13 21:24:13 +00:00
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
}
2022-09-09 20:26:55 +00:00
// t.GasCharges ([]vm.FvmGasCharge) (slice)
2022-09-20 15:30:07 +00:00
if len(t.GasCharges) > 1000000000 {
2022-09-09 20:26:55 +00:00
return xerrors.Errorf("Slice value in field t.GasCharges was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.GasCharges))); err != nil {
return err
}
for _, v := range t.GasCharges {
if err := v.MarshalCBOR(cw); err != nil {
return err
}
}
2022-03-13 21:24:13 +00:00
// t.Subcalls ([]vm.FvmExecutionTrace) (slice)
2022-09-20 15:30:07 +00:00
if len(t.Subcalls) > 1000000000 {
2022-03-13 21:24:13 +00:00
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")
}
2022-09-09 20:26:55 +00:00
if extra != 5 {
2022-03-13 21:24:13 +00:00
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)
}
2022-09-09 20:26:55 +00:00
// t.GasCharges ([]vm.FvmGasCharge) (slice)
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
2022-09-20 15:30:07 +00:00
if extra > 1000000000 {
2022-09-09 20:26:55 +00:00
return fmt.Errorf("t.GasCharges: array too large (%d)", extra)
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.GasCharges = make([]FvmGasCharge, extra)
}
for i := 0; i < int(extra); i++ {
var v FvmGasCharge
if err := v.UnmarshalCBOR(cr); err != nil {
return err
}
t.GasCharges[i] = v
}
2022-03-13 21:24:13 +00:00
// 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
}
2022-09-20 15:30:07 +00:00
if extra > 1000000000 {
2022-03-13 21:24:13 +00:00
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
}
2022-09-09 20:26:55 +00:00
var lengthBufFvmGasCharge = []byte{132}
func (t *FvmGasCharge) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
cw := cbg.NewCborWriter(w)
if _, err := cw.Write(lengthBufFvmGasCharge); err != nil {
return err
}
// t.Name (string) (string)
if len(t.Name) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.Name was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil {
return err
}
if _, err := io.WriteString(w, string(t.Name)); err != nil {
return err
}
// t.TotalGas (int64) (int64)
if t.TotalGas >= 0 {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.TotalGas)); err != nil {
return err
}
} else {
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.TotalGas-1)); err != nil {
return err
}
}
// t.ComputeGas (int64) (int64)
if t.ComputeGas >= 0 {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.ComputeGas)); err != nil {
return err
}
} else {
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.ComputeGas-1)); err != nil {
return err
}
}
// t.StorageGas (int64) (int64)
if t.StorageGas >= 0 {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.StorageGas)); err != nil {
return err
}
} else {
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.StorageGas-1)); err != nil {
return err
}
}
return nil
}
func (t *FvmGasCharge) UnmarshalCBOR(r io.Reader) (err error) {
*t = FvmGasCharge{}
cr := cbg.NewCborReader(r)
maj, extra, err := cr.ReadHeader()
if err != nil {
return err
}
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
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.Name (string) (string)
{
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
t.Name = string(sval)
}
// t.TotalGas (int64) (int64)
{
maj, extra, err := cr.ReadHeader()
var extraI int64
if err != nil {
return err
}
switch maj {
case cbg.MajUnsignedInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 positive overflow")
}
case cbg.MajNegativeInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 negative oveflow")
}
extraI = -1 - extraI
default:
return fmt.Errorf("wrong type for int64 field: %d", maj)
}
t.TotalGas = int64(extraI)
}
// t.ComputeGas (int64) (int64)
{
maj, extra, err := cr.ReadHeader()
var extraI int64
if err != nil {
return err
}
switch maj {
case cbg.MajUnsignedInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 positive overflow")
}
case cbg.MajNegativeInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 negative oveflow")
}
extraI = -1 - extraI
default:
return fmt.Errorf("wrong type for int64 field: %d", maj)
}
t.ComputeGas = int64(extraI)
}
// t.StorageGas (int64) (int64)
{
maj, extra, err := cr.ReadHeader()
var extraI int64
if err != nil {
return err
}
switch maj {
case cbg.MajUnsignedInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 positive overflow")
}
case cbg.MajNegativeInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 negative oveflow")
}
extraI = -1 - extraI
default:
return fmt.Errorf("wrong type for int64 field: %d", maj)
}
t.StorageGas = int64(extraI)
}
return nil
}