lotus/chain/exchange/cbor_gen.go

796 lines
14 KiB
Go
Raw Normal View History

// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
package exchange
2019-08-22 01:29:19 +00:00
import (
"fmt"
"io"
integrate DAG store and CARv2 in deal-making (#6671) This commit removes badger from the deal-making processes, and moves to a new architecture with the dagstore as the cental component on the miner-side, and CARv2s on the client-side. Every deal that has been handed off to the sealing subsystem becomes a shard in the dagstore. Shards are mounted via the LotusMount, which teaches the dagstore how to load the related piece when serving retrievals. When the miner starts the Lotus for the first time with this patch, we will perform a one-time migration of all active deals into the dagstore. This is a lightweight process, and it consists simply of registering the shards in the dagstore. Shards are backed by the unsealed copy of the piece. This is currently a CARv1. However, the dagstore keeps CARv2 indices for all pieces, so when it's time to acquire a shard to serve a retrieval, the unsealed CARv1 is joined with its index (safeguarded by the dagstore), to form a read-only blockstore, thus taking the place of the monolithic badger. Data transfers have been adjusted to interface directly with CARv2 files. On inbound transfers (client retrievals, miner storage deals), we stream the received data into a CARv2 ReadWrite blockstore. On outbound transfers (client storage deals, miner retrievals), we serve the data off a CARv2 ReadOnly blockstore. Client-side imports are managed by the refactored *imports.Manager component (when not using IPFS integration). Just like it before, we use the go-filestore library to avoid duplicating the data from the original file in the resulting UnixFS DAG (concretely the leaves). However, the target of those imports are what we call "ref-CARv2s": CARv2 files placed under the `$LOTUS_PATH/imports` directory, containing the intermediate nodes in full, and the leaves as positional references to the original file on disk. Client-side retrievals are placed into CARv2 files in the location: `$LOTUS_PATH/retrievals`. A new set of `Dagstore*` JSON-RPC operations and `lotus-miner dagstore` subcommands have been introduced on the miner-side to inspect and manage the dagstore. Despite moving to a CARv2-backed system, the IPFS integration has been respected, and it continues to be possible to make storage deals with data held in an IPFS node, and to perform retrievals directly into an IPFS node. NOTE: because the "staging" and "client" Badger blockstores are no longer used, existing imports on the client will be rendered useless. On startup, Lotus will enumerate all imports and print WARN statements on the log for each import that needs to be reimported. These log lines contain these messages: - import lacks carv2 path; import will not work; please reimport - import has missing/broken carv2; please reimport At the end, we will print a "sanity check completed" message indicating the count of imports found, and how many were deemed broken. Co-authored-by: Aarsh Shah <aarshkshah1992@gmail.com> Co-authored-by: Dirk McCormick <dirkmdev@gmail.com> Co-authored-by: Raúl Kripalani <raul@protocol.ai> Co-authored-by: Dirk McCormick <dirkmdev@gmail.com>
2021-08-16 22:34:32 +00:00
"math"
"sort"
2019-08-22 01:29:19 +00:00
2020-08-20 04:37:21 +00:00
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"
2022-06-14 15:00:51 +00:00
types "github.com/filecoin-project/lotus/chain/types"
2019-08-22 01:29:19 +00:00
)
var _ = xerrors.Errorf
var _ = cid.Undef
integrate DAG store and CARv2 in deal-making (#6671) This commit removes badger from the deal-making processes, and moves to a new architecture with the dagstore as the cental component on the miner-side, and CARv2s on the client-side. Every deal that has been handed off to the sealing subsystem becomes a shard in the dagstore. Shards are mounted via the LotusMount, which teaches the dagstore how to load the related piece when serving retrievals. When the miner starts the Lotus for the first time with this patch, we will perform a one-time migration of all active deals into the dagstore. This is a lightweight process, and it consists simply of registering the shards in the dagstore. Shards are backed by the unsealed copy of the piece. This is currently a CARv1. However, the dagstore keeps CARv2 indices for all pieces, so when it's time to acquire a shard to serve a retrieval, the unsealed CARv1 is joined with its index (safeguarded by the dagstore), to form a read-only blockstore, thus taking the place of the monolithic badger. Data transfers have been adjusted to interface directly with CARv2 files. On inbound transfers (client retrievals, miner storage deals), we stream the received data into a CARv2 ReadWrite blockstore. On outbound transfers (client storage deals, miner retrievals), we serve the data off a CARv2 ReadOnly blockstore. Client-side imports are managed by the refactored *imports.Manager component (when not using IPFS integration). Just like it before, we use the go-filestore library to avoid duplicating the data from the original file in the resulting UnixFS DAG (concretely the leaves). However, the target of those imports are what we call "ref-CARv2s": CARv2 files placed under the `$LOTUS_PATH/imports` directory, containing the intermediate nodes in full, and the leaves as positional references to the original file on disk. Client-side retrievals are placed into CARv2 files in the location: `$LOTUS_PATH/retrievals`. A new set of `Dagstore*` JSON-RPC operations and `lotus-miner dagstore` subcommands have been introduced on the miner-side to inspect and manage the dagstore. Despite moving to a CARv2-backed system, the IPFS integration has been respected, and it continues to be possible to make storage deals with data held in an IPFS node, and to perform retrievals directly into an IPFS node. NOTE: because the "staging" and "client" Badger blockstores are no longer used, existing imports on the client will be rendered useless. On startup, Lotus will enumerate all imports and print WARN statements on the log for each import that needs to be reimported. These log lines contain these messages: - import lacks carv2 path; import will not work; please reimport - import has missing/broken carv2; please reimport At the end, we will print a "sanity check completed" message indicating the count of imports found, and how many were deemed broken. Co-authored-by: Aarsh Shah <aarshkshah1992@gmail.com> Co-authored-by: Dirk McCormick <dirkmdev@gmail.com> Co-authored-by: Raúl Kripalani <raul@protocol.ai> Co-authored-by: Dirk McCormick <dirkmdev@gmail.com>
2021-08-16 22:34:32 +00:00
var _ = math.E
var _ = sort.Sort
2019-08-22 01:29:19 +00:00
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
}
2022-05-23 19:11:46 +00:00
cw := cbg.NewCborWriter(w)
if _, err := cw.Write(lengthBufRequest); err != nil {
2019-08-22 01:29:19 +00:00
return err
}
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
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(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 {
2023-09-23 21:21:22 +00:00
if err := cbg.WriteCid(cw, v); err != nil {
return xerrors.Errorf("failed to write cid field v: %w", err)
2019-08-22 01:29:19 +00:00
}
2023-09-23 21:21:22 +00:00
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
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(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
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(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
}
2022-05-23 19:11:46 +00:00
func (t *Request) UnmarshalCBOR(r io.Reader) (err error) {
2020-08-03 15:23:11 +00:00
*t = Request{}
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2019-08-22 01:29:19 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2019-08-22 01:29:19 +00:00
if err != nil {
return err
}
2022-05-23 19:11:46 +00:00
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
2019-08-22 01:29:19 +00:00
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
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
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++ {
2023-09-23 21:21:22 +00:00
{
var maj byte
var extra uint64
var err error
_ = maj
_ = extra
_ = err
2019-08-22 01:29:19 +00:00
2023-09-23 21:21:22 +00:00
{
c, err := cbg.ReadCid(cr)
if err != nil {
return xerrors.Errorf("failed to read cid field t.Head[i]: %w", err)
}
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
{
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
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
{
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
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
}
2022-05-23 19:11:46 +00:00
cw := cbg.NewCborWriter(w)
if _, err := cw.Write(lengthBufResponse); err != nil {
2019-08-22 01:29:19 +00:00
return err
}
2020-09-17 15:37:16 +00:00
// t.Status (exchange.status) (uint64)
2019-12-16 23:44:14 +00:00
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(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
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.ErrorMessage))); err != nil {
2020-08-03 15:23:11 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.ErrorMessage)); err != nil {
2019-08-22 01:29:19 +00:00
return err
}
2020-09-17 15:37:16 +00:00
// t.Chain ([]*exchange.BSTipSet) (slice)
2020-08-03 15:23:11 +00:00
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
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(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 {
2022-05-23 19:11:46 +00:00
if err := v.MarshalCBOR(cw); err != nil {
2020-08-03 15:23:11 +00:00
return err
}
2019-08-22 01:29:19 +00:00
}
return nil
}
2022-05-23 19:11:46 +00:00
func (t *Response) UnmarshalCBOR(r io.Reader) (err error) {
2020-08-03 15:23:11 +00:00
*t = Response{}
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2019-08-22 01:29:19 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2019-08-22 01:29:19 +00:00
if err != nil {
return err
}
2022-05-23 19:11:46 +00:00
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
2019-08-22 01:29:19 +00:00
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-09-17 15:37:16 +00:00
// t.Status (exchange.status) (uint64)
2020-08-03 15:23:11 +00:00
{
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
2020-08-03 15:23:11 +00:00
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)
{
2022-05-23 19:11:46 +00:00
sval, err := cbg.ReadString(cr)
2020-08-03 15:23:11 +00:00
if err != nil {
return err
}
t.ErrorMessage = string(sval)
}
2020-09-17 15:37:16 +00:00
// t.Chain ([]*exchange.BSTipSet) (slice)
2019-08-22 01:29:19 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
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++ {
2023-09-23 21:21:22 +00:00
{
var maj byte
var extra uint64
var err error
_ = maj
_ = extra
_ = err
2019-11-09 23:00:22 +00:00
2023-09-23 21:21:22 +00:00
{
2019-08-22 01:29:19 +00:00
2023-09-23 21:21:22 +00:00
b, err := cr.ReadByte()
if err != nil {
return err
}
if b != cbg.CborNull[0] {
if err := cr.UnreadByte(); err != nil {
return err
}
t.Chain[i] = new(BSTipSet)
if err := t.Chain[i].UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.Chain[i] pointer: %w", err)
}
}
}
}
2019-08-22 01:29:19 +00:00
}
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
}
2022-05-23 19:11:46 +00:00
cw := cbg.NewCborWriter(w)
if _, err := cw.Write(lengthBufCompactedMessages); err != nil {
2019-08-22 01:29:19 +00:00
return err
}
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
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(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 {
2022-05-23 19:11:46 +00:00
if err := v.MarshalCBOR(cw); err != nil {
2019-08-22 01:29:19 +00:00
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
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(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")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(v))); err != nil {
2019-08-22 01:29:19 +00:00
return err
}
for _, v := range v {
2023-09-23 21:21:22 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(v)); err != nil {
2019-08-22 01:29:19 +00:00
return err
}
2023-09-23 21:21:22 +00:00
2019-08-22 01:29:19 +00:00
}
}
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
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(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 {
2022-05-23 19:11:46 +00:00
if err := v.MarshalCBOR(cw); err != nil {
2019-08-22 01:29:19 +00:00
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
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(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")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(v))); err != nil {
2019-08-22 01:29:19 +00:00
return err
}
for _, v := range v {
2023-09-23 21:21:22 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(v)); err != nil {
2019-08-22 01:29:19 +00:00
return err
}
2023-09-23 21:21:22 +00:00
2019-08-22 01:29:19 +00:00
}
}
return nil
}
2022-05-23 19:11:46 +00:00
func (t *CompactedMessages) UnmarshalCBOR(r io.Reader) (err error) {
2020-08-03 15:23:11 +00:00
*t = CompactedMessages{}
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2019-08-22 01:29:19 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2019-08-22 01:29:19 +00:00
if err != nil {
return err
}
2022-05-23 19:11:46 +00:00
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
2019-08-22 01:29:19 +00:00
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
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
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++ {
2023-09-23 21:21:22 +00:00
{
var maj byte
var extra uint64
var err error
_ = maj
_ = extra
_ = err
2019-11-09 23:00:22 +00:00
2023-09-23 21:21:22 +00:00
{
2019-08-22 01:29:19 +00:00
2023-09-23 21:21:22 +00:00
b, err := cr.ReadByte()
if err != nil {
return err
}
if b != cbg.CborNull[0] {
if err := cr.UnreadByte(); err != nil {
return err
}
t.Bls[i] = new(types.Message)
if err := t.Bls[i].UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.Bls[i] pointer: %w", err)
}
}
}
}
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
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
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
2023-09-23 21:21:22 +00:00
_ = maj
_ = extra
_ = err
2019-08-22 01:29:19 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
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++ {
2023-09-23 21:21:22 +00:00
{
var maj byte
var extra uint64
var err error
_ = maj
_ = extra
_ = err
{
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.BlsIncludes[i][j] = uint64(extra)
}
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
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
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++ {
2023-09-23 21:21:22 +00:00
{
var maj byte
var extra uint64
var err error
_ = maj
_ = extra
_ = err
2019-11-09 23:00:22 +00:00
2023-09-23 21:21:22 +00:00
{
2019-08-22 01:29:19 +00:00
2023-09-23 21:21:22 +00:00
b, err := cr.ReadByte()
if err != nil {
return err
}
if b != cbg.CborNull[0] {
if err := cr.UnreadByte(); err != nil {
return err
}
t.Secpk[i] = new(types.SignedMessage)
if err := t.Secpk[i].UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.Secpk[i] pointer: %w", err)
}
}
}
}
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
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
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
2023-09-23 21:21:22 +00:00
_ = maj
_ = extra
_ = err
2019-08-22 01:29:19 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
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++ {
2023-09-23 21:21:22 +00:00
{
var maj byte
var extra uint64
var err error
_ = maj
_ = extra
_ = err
{
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.SecpkIncludes[i][j] = uint64(extra)
}
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
}
2022-05-23 19:11:46 +00:00
cw := cbg.NewCborWriter(w)
if _, err := cw.Write(lengthBufBSTipSet); err != nil {
2020-08-03 15:23:11 +00:00
return err
}
// t.Blocks ([]*types.BlockHeader) (slice)
if len(t.Blocks) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Blocks was too long")
}
2022-05-23 19:11:46 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Blocks))); err != nil {
2020-08-03 15:23:11 +00:00
return err
}
for _, v := range t.Blocks {
2022-05-23 19:11:46 +00:00
if err := v.MarshalCBOR(cw); err != nil {
2020-08-03 15:23:11 +00:00
return err
}
}
2020-09-17 15:37:16 +00:00
// t.Messages (exchange.CompactedMessages) (struct)
2022-05-23 19:11:46 +00:00
if err := t.Messages.MarshalCBOR(cw); err != nil {
2020-08-03 15:23:11 +00:00
return err
}
return nil
}
2022-05-23 19:11:46 +00:00
func (t *BSTipSet) UnmarshalCBOR(r io.Reader) (err error) {
2020-08-03 15:23:11 +00:00
*t = BSTipSet{}
2022-05-23 19:11:46 +00:00
cr := cbg.NewCborReader(r)
2020-08-03 15:23:11 +00:00
2022-05-23 19:11:46 +00:00
maj, extra, err := cr.ReadHeader()
2020-08-03 15:23:11 +00:00
if err != nil {
return err
}
2022-05-23 19:11:46 +00:00
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
2020-08-03 15:23:11 +00:00
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)
2022-05-23 19:11:46 +00:00
maj, extra, err = cr.ReadHeader()
2020-08-03 15:23:11 +00:00
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++ {
2023-09-23 21:21:22 +00:00
{
var maj byte
var extra uint64
var err error
_ = maj
_ = extra
_ = err
2020-08-03 15:23:11 +00:00
2023-09-23 21:21:22 +00:00
{
2020-08-03 15:23:11 +00:00
2023-09-23 21:21:22 +00:00
b, err := cr.ReadByte()
if err != nil {
return err
}
if b != cbg.CborNull[0] {
if err := cr.UnreadByte(); err != nil {
return err
}
t.Blocks[i] = new(types.BlockHeader)
if err := t.Blocks[i].UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.Blocks[i] pointer: %w", err)
}
}
}
}
2020-08-03 15:23:11 +00:00
}
2020-09-17 15:37:16 +00:00
// t.Messages (exchange.CompactedMessages) (struct)
2020-08-03 15:23:11 +00:00
{
2022-05-23 19:11:46 +00:00
b, err := cr.ReadByte()
2020-08-03 15:23:11 +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 {
2020-08-03 15:23:11 +00:00
return err
}
t.Messages = new(CompactedMessages)
2022-05-23 19:11:46 +00:00
if err := t.Messages.UnmarshalCBOR(cr); err != nil {
2020-08-03 15:23:11 +00:00
return xerrors.Errorf("unmarshaling t.Messages pointer: %w", err)
}
}
}
return nil
}