2020-02-05 02:26:42 +00:00
|
|
|
// 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"
|
|
|
|
|
2020-08-20 04:37:21 +00:00
|
|
|
types "github.com/filecoin-project/lotus/chain/types"
|
|
|
|
cid "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
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
var lengthBufRequest = []byte{131}
|
2020-05-04 22:19:48 +00:00
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
func (t *Request) MarshalCBOR(w io.Writer) error {
|
2019-11-09 23:00:22 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2020-08-03 15:23:11 +00:00
|
|
|
if _, err := w.Write(lengthBufRequest); err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
scratch := make([]byte, 9)
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.Head ([]cid.Cid) (slice)
|
|
|
|
if len(t.Head) > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Slice value in field t.Head was too long")
|
2019-12-16 23:44:14 +00:00
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Head))); err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
return err
|
|
|
|
}
|
2020-08-03 15:23:11 +00:00
|
|
|
for _, v := range t.Head {
|
2020-05-04 22:19:48 +00:00
|
|
|
if err := cbg.WriteCidBuf(scratch, w, v); err != nil {
|
2020-08-03 15:23:11 +00:00
|
|
|
return xerrors.Errorf("failed writing cid field t.Head: %w", err)
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.Length (uint64) (uint64)
|
2020-02-23 00:47:47 +00:00
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Length)); 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
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, 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
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
func (t *Request) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
*t = Request{}
|
2020-07-14 11:45:45 +00:00
|
|
|
|
2019-11-09 23:00:22 +00:00
|
|
|
br := cbg.GetPeeker(r)
|
2020-05-04 22:19:48 +00:00
|
|
|
scratch := make([]byte, 8)
|
2019-08-22 01:29:19 +00:00
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
2019-08-22 01:29:19 +00:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.Head ([]cid.Cid) (slice)
|
2019-08-22 01:29:19 +00:00
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
2019-08-22 01:29:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
|
|
|
|
if extra > cbg.MaxLength {
|
2020-08-03 15:23:11 +00:00
|
|
|
return fmt.Errorf("t.Head: 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 {
|
2020-08-03 15:23:11 +00:00
|
|
|
t.Head = make([]cid.Cid, extra)
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
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 {
|
2020-08-03 15:23:11 +00:00
|
|
|
return xerrors.Errorf("reading cid field t.Head failed: %w", err)
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
2020-08-03 15:23:11 +00:00
|
|
|
t.Head[i] = c
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.Length (uint64) (uint64)
|
2019-08-22 01:29:19 +00:00
|
|
|
|
2020-02-23 00:47:47 +00:00
|
|
|
{
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
2020-02-23 00:47:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
2020-08-03 15:23:11 +00:00
|
|
|
t.Length = uint64(extra)
|
2020-02-23 00:47:47 +00:00
|
|
|
|
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
|
|
|
{
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
2020-02-23 00:47:47 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
var lengthBufResponse = []byte{131}
|
2020-05-04 22:19:48 +00:00
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
func (t *Response) MarshalCBOR(w io.Writer) error {
|
2019-11-09 23:00:22 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2020-08-03 15:23:11 +00:00
|
|
|
if _, err := w.Write(lengthBufResponse); err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
scratch := make([]byte, 9)
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.Status (blocksync.status) (uint64)
|
2019-12-16 23:44:14 +00:00
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Status)); err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.ErrorMessage (string) (string)
|
|
|
|
if len(t.ErrorMessage) > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Value in field t.ErrorMessage was too long")
|
|
|
|
}
|
2020-02-23 00:47:47 +00:00
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len(t.ErrorMessage))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := io.WriteString(w, string(t.ErrorMessage)); err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.Chain ([]*blocksync.BSTipSet) (slice)
|
|
|
|
if len(t.Chain) > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Slice value in field t.Chain was too long")
|
2019-12-16 23:44:14 +00:00
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Chain))); err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
return err
|
|
|
|
}
|
2020-08-03 15:23:11 +00:00
|
|
|
for _, v := range t.Chain {
|
|
|
|
if err := v.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
func (t *Response) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
*t = Response{}
|
2020-07-14 11:45:45 +00:00
|
|
|
|
2019-11-09 23:00:22 +00:00
|
|
|
br := cbg.GetPeeker(r)
|
2020-05-04 22:19:48 +00:00
|
|
|
scratch := make([]byte, 8)
|
2019-08-22 01:29:19 +00:00
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
2019-08-22 01:29:19 +00:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.Status (blocksync.status) (uint64)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
|
|
|
t.Status = status(extra)
|
|
|
|
|
|
|
|
}
|
|
|
|
// t.ErrorMessage (string) (string)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadStringBuf(br, scratch)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.ErrorMessage = string(sval)
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Chain ([]*blocksync.BSTipSet) (slice)
|
2019-08-22 01:29:19 +00:00
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
2019-08-22 01:29:19 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
var lengthBufCompactedMessages = []byte{132}
|
2020-05-04 22:19:48 +00:00
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
func (t *CompactedMessages) MarshalCBOR(w io.Writer) error {
|
2019-11-09 23:00:22 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2020-08-03 15:23:11 +00:00
|
|
|
if _, err := w.Write(lengthBufCompactedMessages); err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
scratch := make([]byte, 9)
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.Bls ([]*types.Message) (slice)
|
|
|
|
if len(t.Bls) > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Slice value in field t.Bls was too long")
|
2019-12-16 23:44:14 +00:00
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Bls))); err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
return err
|
|
|
|
}
|
2020-08-03 15:23:11 +00:00
|
|
|
for _, v := range t.Bls {
|
2019-08-22 01:29:19 +00:00
|
|
|
if err := v.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.BlsIncludes ([][]uint64) (slice)
|
|
|
|
if len(t.BlsIncludes) > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Slice value in field t.BlsIncludes was too long")
|
2019-12-16 23:44:14 +00:00
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.BlsIncludes))); err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
return err
|
|
|
|
}
|
2020-08-03 15:23:11 +00:00
|
|
|
for _, v := range t.BlsIncludes {
|
2019-12-16 23:44:14 +00:00
|
|
|
if len(v) > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Slice value in field v was too long")
|
|
|
|
}
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(v))); err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.Secpk ([]*types.SignedMessage) (slice)
|
|
|
|
if len(t.Secpk) > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Slice value in field t.Secpk was too long")
|
2019-12-16 23:44:14 +00:00
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Secpk))); err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
return err
|
|
|
|
}
|
2020-08-03 15:23:11 +00:00
|
|
|
for _, v := range t.Secpk {
|
2019-08-22 01:29:19 +00:00
|
|
|
if err := v.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.SecpkIncludes ([][]uint64) (slice)
|
|
|
|
if len(t.SecpkIncludes) > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Slice value in field t.SecpkIncludes was too long")
|
2019-12-16 23:44:14 +00:00
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.SecpkIncludes))); err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
return err
|
|
|
|
}
|
2020-08-03 15:23:11 +00:00
|
|
|
for _, v := range t.SecpkIncludes {
|
2019-12-16 23:44:14 +00:00
|
|
|
if len(v) > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Slice value in field v was too long")
|
|
|
|
}
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(v))); err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
func (t *CompactedMessages) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
*t = CompactedMessages{}
|
2020-07-14 11:45:45 +00:00
|
|
|
|
2019-11-09 23:00:22 +00:00
|
|
|
br := cbg.GetPeeker(r)
|
2020-05-04 22:19:48 +00:00
|
|
|
scratch := make([]byte, 8)
|
2019-08-22 01:29:19 +00:00
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
2019-08-22 01:29:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
if extra != 4 {
|
2019-08-22 01:29:19 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.Bls ([]*types.Message) (slice)
|
2019-08-22 01:29:19 +00:00
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
2019-08-22 01:29:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
|
|
|
|
if extra > cbg.MaxLength {
|
2020-08-03 15:23:11 +00:00
|
|
|
return fmt.Errorf("t.Bls: 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 {
|
2020-08-03 15:23:11 +00:00
|
|
|
t.Bls = make([]*types.Message, extra)
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
t.Bls[i] = &v
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.BlsIncludes ([][]uint64) (slice)
|
2019-08-22 01:29:19 +00:00
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
2019-08-22 01:29:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
|
|
|
|
if extra > cbg.MaxLength {
|
2020-08-03 15:23:11 +00:00
|
|
|
return fmt.Errorf("t.BlsIncludes: 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 {
|
2020-08-03 15:23:11 +00:00
|
|
|
t.BlsIncludes = make([][]uint64, extra)
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
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
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
2019-08-22 01:29:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
|
|
|
|
if extra > cbg.MaxLength {
|
2020-08-03 15:23:11 +00:00
|
|
|
return fmt.Errorf("t.BlsIncludes[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 {
|
2020-08-03 15:23:11 +00:00
|
|
|
t.BlsIncludes[i] = make([]uint64, extra)
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
2020-04-17 17:53:09 +00:00
|
|
|
|
2019-08-22 01:29:19 +00:00
|
|
|
for j := 0; j < int(extra); j++ {
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, val, err := cbg.CborReadHeaderBuf(br, scratch)
|
2019-08-22 01:29:19 +00:00
|
|
|
if err != nil {
|
2020-08-03 15:23:11 +00:00
|
|
|
return xerrors.Errorf("failed to read uint64 for t.BlsIncludes[i] slice: %w", err)
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
2020-08-03 15:23:11 +00:00
|
|
|
return xerrors.Errorf("value read for array t.BlsIncludes[i] was not a uint, instead got %d", maj)
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
t.BlsIncludes[i][j] = uint64(val)
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.Secpk ([]*types.SignedMessage) (slice)
|
2019-08-22 01:29:19 +00:00
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
2019-08-22 01:29:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
|
|
|
|
if extra > cbg.MaxLength {
|
2020-08-03 15:23:11 +00:00
|
|
|
return fmt.Errorf("t.Secpk: 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 {
|
2020-08-03 15:23:11 +00:00
|
|
|
t.Secpk = make([]*types.SignedMessage, extra)
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
t.Secpk[i] = &v
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
// t.SecpkIncludes ([][]uint64) (slice)
|
2019-08-22 01:29:19 +00:00
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
2019-08-22 01:29:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
|
|
|
|
if extra > cbg.MaxLength {
|
2020-08-03 15:23:11 +00:00
|
|
|
return fmt.Errorf("t.SecpkIncludes: 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 {
|
2020-08-03 15:23:11 +00:00
|
|
|
t.SecpkIncludes = make([][]uint64, extra)
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
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
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
2019-08-22 01:29:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
|
|
|
|
if extra > cbg.MaxLength {
|
2020-08-03 15:23:11 +00:00
|
|
|
return fmt.Errorf("t.SecpkIncludes[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 {
|
2020-08-03 15:23:11 +00:00
|
|
|
t.SecpkIncludes[i] = make([]uint64, extra)
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
2020-04-17 17:53:09 +00:00
|
|
|
|
2019-08-22 01:29:19 +00:00
|
|
|
for j := 0; j < int(extra); j++ {
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, val, err := cbg.CborReadHeaderBuf(br, scratch)
|
2019-08-22 01:29:19 +00:00
|
|
|
if err != nil {
|
2020-08-03 15:23:11 +00:00
|
|
|
return xerrors.Errorf("failed to read uint64 for t.SecpkIncludes[i] slice: %w", err)
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
2020-08-03 15:23:11 +00:00
|
|
|
return xerrors.Errorf("value read for array t.SecpkIncludes[i] was not a uint, instead got %d", maj)
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
|
|
|
|
2020-08-03 15:23:11 +00:00
|
|
|
t.SecpkIncludes[i][j] = uint64(val)
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2020-08-03 15:23:11 +00:00
|
|
|
|
|
|
|
var lengthBufBSTipSet = []byte{130}
|
|
|
|
|
|
|
|
func (t *BSTipSet) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write(lengthBufBSTipSet); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
scratch := make([]byte, 9)
|
|
|
|
|
|
|
|
// t.Blocks ([]*types.BlockHeader) (slice)
|
|
|
|
if len(t.Blocks) > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Slice value in field t.Blocks was too long")
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Blocks))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.Blocks {
|
|
|
|
if err := v.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Messages (blocksync.CompactedMessages) (struct)
|
|
|
|
if err := t.Messages.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
*t = BSTipSet{}
|
|
|
|
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
scratch := make([]byte, 8)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 2 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Blocks ([]*types.BlockHeader) (slice)
|
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra > cbg.MaxLength {
|
|
|
|
return fmt.Errorf("t.Blocks: array too large (%d)", extra)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra > 0 {
|
|
|
|
t.Blocks = make([]*types.BlockHeader, extra)
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := 0; i < int(extra); i++ {
|
|
|
|
|
|
|
|
var v types.BlockHeader
|
|
|
|
if err := v.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Blocks[i] = &v
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Messages (blocksync.CompactedMessages) (struct)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
2020-08-12 02:47:24 +00:00
|
|
|
b, err := br.ReadByte()
|
2020-08-03 15:23:11 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-12 02:47:24 +00:00
|
|
|
if b != cbg.CborNull[0] {
|
|
|
|
if err := br.UnreadByte(); err != nil {
|
2020-08-03 15:23:11 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
t.Messages = new(CompactedMessages)
|
|
|
|
if err := t.Messages.UnmarshalCBOR(br); err != nil {
|
|
|
|
return xerrors.Errorf("unmarshaling t.Messages pointer: %w", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|