lotus/chain/blocksync/cbor_gen.go

564 lines
12 KiB
Go
Raw Normal View History

// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
2019-11-09 23:00:22 +00:00
package blocksync
2019-08-22 01:29:19 +00:00
import (
"fmt"
"io"
"github.com/filecoin-project/lotus/chain/types"
2020-04-27 18:35:00 +00:00
"github.com/ipfs/go-cid"
2019-08-22 01:29:19 +00:00
cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors"
)
var _ = xerrors.Errorf
func (t *BlockSyncRequest) MarshalCBOR(w io.Writer) error {
2019-11-09 23:00:22 +00:00
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
2019-08-22 01:29:19 +00:00
if _, err := w.Write([]byte{131}); err != nil {
return err
}
2019-12-09 16:40:15 +00:00
// t.Start ([]cid.Cid) (slice)
2019-12-16 23:44:14 +00:00
if len(t.Start) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Start was too long")
}
2019-08-22 01:29:19 +00:00
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Start)))); err != nil {
return err
}
for _, v := range t.Start {
if err := cbg.WriteCid(w, v); err != nil {
return xerrors.Errorf("failed writing cid field t.Start: %w", err)
}
}
2019-12-09 16:40:15 +00:00
// t.RequestLength (uint64) (uint64)
2020-02-23 00:47:47 +00:00
2019-11-09 23:00:22 +00:00
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.RequestLength))); err != nil {
2019-08-22 01:29:19 +00:00
return err
}
2019-12-09 16:40:15 +00:00
// t.Options (uint64) (uint64)
2020-02-23 00:47:47 +00:00
2019-11-09 23:00:22 +00:00
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Options))); err != nil {
2019-08-22 01:29:19 +00:00
return err
}
2020-02-23 00:47:47 +00:00
2019-08-22 01:29:19 +00:00
return nil
}
2019-11-09 23:00:22 +00:00
func (t *BlockSyncRequest) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
2019-08-22 01:29:19 +00:00
maj, extra, err := cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 3 {
return fmt.Errorf("cbor input had wrong number of fields")
}
2019-12-09 16:40:15 +00:00
// t.Start ([]cid.Cid) (slice)
2019-08-22 01:29:19 +00:00
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
2019-12-09 16:40:15 +00:00
if extra > cbg.MaxLength {
2019-11-09 23:00:22 +00:00
return fmt.Errorf("t.Start: array too large (%d)", extra)
2019-08-22 01:29:19 +00:00
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
if extra > 0 {
t.Start = make([]cid.Cid, extra)
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
for i := 0; i < int(extra); i++ {
c, err := cbg.ReadCid(br)
if err != nil {
return xerrors.Errorf("reading cid field t.Start failed: %w", err)
}
t.Start[i] = c
}
2019-12-09 16:40:15 +00:00
// t.RequestLength (uint64) (uint64)
2019-08-22 01:29:19 +00:00
2020-02-23 00:47:47 +00:00
{
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.RequestLength = uint64(extra)
2019-08-22 01:29:19 +00:00
}
2019-12-09 16:40:15 +00:00
// t.Options (uint64) (uint64)
2019-08-22 01:29:19 +00:00
2020-02-23 00:47:47 +00:00
{
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.Options = uint64(extra)
2019-08-22 01:29:19 +00:00
}
return nil
}
func (t *BlockSyncResponse) MarshalCBOR(w io.Writer) error {
2019-11-09 23:00:22 +00:00
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
2019-08-22 01:29:19 +00:00
if _, err := w.Write([]byte{131}); err != nil {
return err
}
2019-12-09 16:40:15 +00:00
// t.Chain ([]*blocksync.BSTipSet) (slice)
2019-12-16 23:44:14 +00:00
if len(t.Chain) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Chain was too long")
}
2019-08-22 01:29:19 +00:00
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Chain)))); err != nil {
return err
}
for _, v := range t.Chain {
if err := v.MarshalCBOR(w); err != nil {
return err
}
}
2019-12-09 16:40:15 +00:00
// t.Status (uint64) (uint64)
2020-02-23 00:47:47 +00:00
2019-11-09 23:00:22 +00:00
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Status))); err != nil {
2019-08-22 01:29:19 +00:00
return err
}
2019-12-09 16:40:15 +00:00
// t.Message (string) (string)
2019-12-16 23:44:14 +00:00
if len(t.Message) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.Message was too long")
}
2019-08-22 01:29:19 +00:00
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.Message)))); err != nil {
return err
}
if _, err := w.Write([]byte(t.Message)); err != nil {
return err
}
return nil
}
2019-11-09 23:00:22 +00:00
func (t *BlockSyncResponse) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
2019-08-22 01:29:19 +00:00
maj, extra, err := cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 3 {
return fmt.Errorf("cbor input had wrong number of fields")
}
2019-12-09 16:40:15 +00:00
// t.Chain ([]*blocksync.BSTipSet) (slice)
2019-08-22 01:29:19 +00:00
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
2019-12-09 16:40:15 +00:00
if extra > cbg.MaxLength {
2019-11-09 23:00:22 +00:00
return fmt.Errorf("t.Chain: array too large (%d)", extra)
2019-08-22 01:29:19 +00:00
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
if extra > 0 {
t.Chain = make([]*BSTipSet, extra)
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
for i := 0; i < int(extra); i++ {
2019-11-09 23:00:22 +00:00
2019-08-22 01:29:19 +00:00
var v BSTipSet
if err := v.UnmarshalCBOR(br); err != nil {
return err
}
t.Chain[i] = &v
}
2019-12-09 16:40:15 +00:00
// t.Status (uint64) (uint64)
2019-08-22 01:29:19 +00:00
2020-02-23 00:47:47 +00:00
{
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.Status = uint64(extra)
2019-08-22 01:29:19 +00:00
}
2019-12-09 16:40:15 +00:00
// t.Message (string) (string)
2019-08-22 01:29:19 +00:00
{
2019-11-09 23:00:22 +00:00
sval, err := cbg.ReadString(br)
if err != nil {
2019-08-22 01:29:19 +00:00
return err
}
2019-11-09 23:00:22 +00:00
t.Message = string(sval)
2019-08-22 01:29:19 +00:00
}
return nil
}
func (t *BSTipSet) MarshalCBOR(w io.Writer) error {
2019-11-09 23:00:22 +00:00
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
2019-08-22 01:29:19 +00:00
if _, err := w.Write([]byte{133}); err != nil {
return err
}
2019-12-09 16:40:15 +00:00
// t.Blocks ([]*types.BlockHeader) (slice)
2019-12-16 23:44:14 +00:00
if len(t.Blocks) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Blocks was too long")
}
2019-08-22 01:29:19 +00:00
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Blocks)))); err != nil {
return err
}
for _, v := range t.Blocks {
if err := v.MarshalCBOR(w); err != nil {
return err
}
}
2019-12-09 16:40:15 +00:00
// t.BlsMessages ([]*types.Message) (slice)
2019-12-16 23:44:14 +00:00
if len(t.BlsMessages) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.BlsMessages was too long")
}
2019-08-22 01:29:19 +00:00
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.BlsMessages)))); err != nil {
return err
}
for _, v := range t.BlsMessages {
if err := v.MarshalCBOR(w); err != nil {
return err
}
}
2019-12-09 16:40:15 +00:00
// t.BlsMsgIncludes ([][]uint64) (slice)
2019-12-16 23:44:14 +00:00
if len(t.BlsMsgIncludes) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.BlsMsgIncludes was too long")
}
2019-08-22 01:29:19 +00:00
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.BlsMsgIncludes)))); err != nil {
return err
}
for _, v := range t.BlsMsgIncludes {
2019-12-16 23:44:14 +00:00
if len(v) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field v was too long")
}
2019-08-22 01:29:19 +00:00
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(v)))); err != nil {
return err
}
for _, v := range v {
2020-02-12 23:52:36 +00:00
if err := cbg.CborWriteHeader(w, cbg.MajUnsignedInt, uint64(v)); err != nil {
2019-08-22 01:29:19 +00:00
return err
}
}
}
2019-12-09 16:40:15 +00:00
// t.SecpkMessages ([]*types.SignedMessage) (slice)
2019-12-16 23:44:14 +00:00
if len(t.SecpkMessages) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.SecpkMessages was too long")
}
2019-08-22 01:29:19 +00:00
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.SecpkMessages)))); err != nil {
return err
}
for _, v := range t.SecpkMessages {
if err := v.MarshalCBOR(w); err != nil {
return err
}
}
2019-12-09 16:40:15 +00:00
// t.SecpkMsgIncludes ([][]uint64) (slice)
2019-12-16 23:44:14 +00:00
if len(t.SecpkMsgIncludes) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.SecpkMsgIncludes was too long")
}
2019-08-22 01:29:19 +00:00
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.SecpkMsgIncludes)))); err != nil {
return err
}
for _, v := range t.SecpkMsgIncludes {
2019-12-16 23:44:14 +00:00
if len(v) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field v was too long")
}
2019-08-22 01:29:19 +00:00
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(v)))); err != nil {
return err
}
for _, v := range v {
2020-02-12 23:52:36 +00:00
if err := cbg.CborWriteHeader(w, cbg.MajUnsignedInt, uint64(v)); err != nil {
2019-08-22 01:29:19 +00:00
return err
}
}
}
return nil
}
2019-11-09 23:00:22 +00:00
func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
2019-08-22 01:29:19 +00:00
maj, extra, err := cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 5 {
return fmt.Errorf("cbor input had wrong number of fields")
}
2019-12-09 16:40:15 +00:00
// t.Blocks ([]*types.BlockHeader) (slice)
2019-08-22 01:29:19 +00:00
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
2019-12-09 16:40:15 +00:00
if extra > cbg.MaxLength {
2019-11-09 23:00:22 +00:00
return fmt.Errorf("t.Blocks: array too large (%d)", extra)
2019-08-22 01:29:19 +00:00
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
if extra > 0 {
t.Blocks = make([]*types.BlockHeader, extra)
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
for i := 0; i < int(extra); i++ {
2019-11-09 23:00:22 +00:00
2019-08-22 01:29:19 +00:00
var v types.BlockHeader
if err := v.UnmarshalCBOR(br); err != nil {
return err
}
t.Blocks[i] = &v
}
2019-12-09 16:40:15 +00:00
// t.BlsMessages ([]*types.Message) (slice)
2019-08-22 01:29:19 +00:00
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
2019-12-09 16:40:15 +00:00
if extra > cbg.MaxLength {
2019-11-09 23:00:22 +00:00
return fmt.Errorf("t.BlsMessages: array too large (%d)", extra)
2019-08-22 01:29:19 +00:00
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
if extra > 0 {
t.BlsMessages = make([]*types.Message, extra)
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
for i := 0; i < int(extra); i++ {
2019-11-09 23:00:22 +00:00
2019-08-22 01:29:19 +00:00
var v types.Message
if err := v.UnmarshalCBOR(br); err != nil {
return err
}
t.BlsMessages[i] = &v
}
2019-12-09 16:40:15 +00:00
// t.BlsMsgIncludes ([][]uint64) (slice)
2019-08-22 01:29:19 +00:00
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
2019-12-09 16:40:15 +00:00
if extra > cbg.MaxLength {
2019-11-09 23:00:22 +00:00
return fmt.Errorf("t.BlsMsgIncludes: array too large (%d)", extra)
2019-08-22 01:29:19 +00:00
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
if extra > 0 {
t.BlsMsgIncludes = make([][]uint64, extra)
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
for i := 0; i < int(extra); i++ {
{
var maj byte
var extra uint64
var err error
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
2019-12-09 16:40:15 +00:00
if extra > cbg.MaxLength {
2019-11-09 23:00:22 +00:00
return fmt.Errorf("t.BlsMsgIncludes[i]: array too large (%d)", extra)
2019-08-22 01:29:19 +00:00
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
if extra > 0 {
t.BlsMsgIncludes[i] = make([]uint64, extra)
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
for j := 0; j < int(extra); j++ {
maj, val, err := cbg.CborReadHeader(br)
if err != nil {
return xerrors.Errorf("failed to read uint64 for t.BlsMsgIncludes[i] slice: %w", err)
}
if maj != cbg.MajUnsignedInt {
return xerrors.Errorf("value read for array t.BlsMsgIncludes[i] was not a uint, instead got %d", maj)
}
2020-02-12 23:52:36 +00:00
t.BlsMsgIncludes[i][j] = uint64(val)
2019-08-22 01:29:19 +00:00
}
}
}
2019-12-09 16:40:15 +00:00
// t.SecpkMessages ([]*types.SignedMessage) (slice)
2019-08-22 01:29:19 +00:00
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
2019-12-09 16:40:15 +00:00
if extra > cbg.MaxLength {
2019-11-09 23:00:22 +00:00
return fmt.Errorf("t.SecpkMessages: array too large (%d)", extra)
2019-08-22 01:29:19 +00:00
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
if extra > 0 {
t.SecpkMessages = make([]*types.SignedMessage, extra)
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
for i := 0; i < int(extra); i++ {
2019-11-09 23:00:22 +00:00
2019-08-22 01:29:19 +00:00
var v types.SignedMessage
if err := v.UnmarshalCBOR(br); err != nil {
return err
}
t.SecpkMessages[i] = &v
}
2019-12-09 16:40:15 +00:00
// t.SecpkMsgIncludes ([][]uint64) (slice)
2019-08-22 01:29:19 +00:00
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
2019-12-09 16:40:15 +00:00
if extra > cbg.MaxLength {
2019-11-09 23:00:22 +00:00
return fmt.Errorf("t.SecpkMsgIncludes: array too large (%d)", extra)
2019-08-22 01:29:19 +00:00
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
if extra > 0 {
t.SecpkMsgIncludes = make([][]uint64, extra)
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
for i := 0; i < int(extra); i++ {
{
var maj byte
var extra uint64
var err error
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
2019-12-09 16:40:15 +00:00
if extra > cbg.MaxLength {
2019-11-09 23:00:22 +00:00
return fmt.Errorf("t.SecpkMsgIncludes[i]: array too large (%d)", extra)
2019-08-22 01:29:19 +00:00
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
if extra > 0 {
t.SecpkMsgIncludes[i] = make([]uint64, extra)
}
2020-04-17 17:53:09 +00:00
2019-08-22 01:29:19 +00:00
for j := 0; j < int(extra); j++ {
maj, val, err := cbg.CborReadHeader(br)
if err != nil {
return xerrors.Errorf("failed to read uint64 for t.SecpkMsgIncludes[i] slice: %w", err)
}
if maj != cbg.MajUnsignedInt {
return xerrors.Errorf("value read for array t.SecpkMsgIncludes[i] was not a uint, instead got %d", maj)
}
2020-02-12 23:52:36 +00:00
t.SecpkMsgIncludes[i][j] = uint64(val)
2019-08-22 01:29:19 +00:00
}
}
}
return nil
}