lotus/storage/pipeline/cbor_gen.go

1904 lines
44 KiB
Go
Raw Normal View History

// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
package sealing
import (
2020-04-06 20:35:29 +00:00
"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"
cid "github.com/ipfs/go-cid"
2020-04-06 20:35:29 +00:00
cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors"
2022-09-07 23:30:55 +00:00
abi "github.com/filecoin-project/go-state-types/abi"
api "github.com/filecoin-project/lotus/api"
2022-09-02 15:12:58 +00:00
storiface "github.com/filecoin-project/lotus/storage/sealer/storiface"
)
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
func (t *SectorInfo) MarshalCBOR(w io.Writer) error {
2020-04-06 20:35:29 +00:00
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
2022-04-20 21:34:28 +00:00
cw := cbg.NewCborWriter(w)
2023-07-18 18:55:14 +00:00
if _, err := cw.Write([]byte{184, 39}); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2020-01-22 02:41:39 +00:00
// t.Log ([]sealing.Log) (slice)
if len("Log") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Log\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Log"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Log")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if len(t.Log) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Log was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Log))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
for _, v := range t.Log {
if err := v.MarshalCBOR(cw); err != nil {
return err
}
2020-04-06 20:35:29 +00:00
}
// t.CommD (cid.Cid) (struct)
if len("CommD") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"CommD\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("CommD"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("CommD")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if t.CommD == nil {
if _, err := cw.Write(cbg.CborNull); err != nil {
return err
}
} else {
if err := cbg.WriteCid(cw, *t.CommD); err != nil {
return xerrors.Errorf("failed to write cid field t.CommD: %w", err)
}
2020-04-06 20:35:29 +00:00
}
// t.CommR (cid.Cid) (struct)
if len("CommR") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"CommR\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("CommR"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("CommR")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if t.CommR == nil {
if _, err := cw.Write(cbg.CborNull); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
} else {
if err := cbg.WriteCid(cw, *t.CommR); err != nil {
return xerrors.Errorf("failed to write cid field t.CommR: %w", err)
2020-04-06 20:35:29 +00:00
}
}
// t.Proof ([]uint8) (slice)
if len("Proof") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Proof\" was too long")
2021-01-18 21:05:56 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Proof"))); err != nil {
2021-01-18 21:05:56 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Proof")); err != nil {
2021-01-18 21:05:56 +00:00
return err
}
if len(t.Proof) > cbg.ByteArrayMaxLen {
return xerrors.Errorf("Byte array in field t.Proof was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajByteString, uint64(len(t.Proof))); err != nil {
return err
}
if _, err := cw.Write(t.Proof[:]); err != nil {
return err
}
// t.State (sealing.SectorState) (string)
if len("State") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"State\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("State"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("State")); err != nil {
return err
}
if len(t.State) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.State was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.State))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.State)); err != nil {
return err
2021-01-18 21:05:56 +00:00
}
2022-08-26 00:37:36 +00:00
// t.Pieces ([]api.SectorPiece) (slice)
if len("Pieces") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Pieces\" was too long")
2020-04-06 20:35:29 +00:00
}
2022-04-20 21:34:28 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Pieces"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Pieces")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if len(t.Pieces) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Pieces was too long")
2020-04-06 20:35:29 +00:00
}
2022-04-20 21:34:28 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Pieces))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
for _, v := range t.Pieces {
2022-04-20 21:34:28 +00:00
if err := v.MarshalCBOR(cw); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
}
// t.Return (sealing.ReturnState) (string)
if len("Return") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Return\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Return"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Return")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if len(t.Return) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.Return was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Return))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.Return)); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
// t.LastErr (string) (string)
if len("LastErr") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"LastErr\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("LastErr"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("LastErr")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if len(t.LastErr) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.LastErr was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.LastErr))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.LastErr)); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
// t.CCPieces ([]api.SectorPiece) (slice)
if len("CCPieces") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"CCPieces\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("CCPieces"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("CCPieces")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if len(t.CCPieces) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.CCPieces was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.CCPieces))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
for _, v := range t.CCPieces {
if err := v.MarshalCBOR(cw); err != nil {
return err
}
}
2020-04-06 20:35:29 +00:00
// t.CCUpdate (bool) (bool)
if len("CCUpdate") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"CCUpdate\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("CCUpdate"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("CCUpdate")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if err := cbg.WriteBool(w, t.CCUpdate); err != nil {
return err
2020-04-06 20:35:29 +00:00
}
// t.SeedEpoch (abi.ChainEpoch) (int64)
if len("SeedEpoch") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"SeedEpoch\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("SeedEpoch"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("SeedEpoch")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if t.SeedEpoch >= 0 {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SeedEpoch)); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
} else {
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.SeedEpoch-1)); err != nil {
return err
2020-04-06 20:35:29 +00:00
}
}
// t.SeedValue (abi.InteractiveSealRandomness) (slice)
if len("SeedValue") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"SeedValue\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("SeedValue"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("SeedValue")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if len(t.SeedValue) > cbg.ByteArrayMaxLen {
return xerrors.Errorf("Byte array in field t.SeedValue was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajByteString, uint64(len(t.SeedValue))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if _, err := cw.Write(t.SeedValue[:]); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
// t.SectorType (abi.RegisteredSealProof) (int64)
if len("SectorType") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"SectorType\" was too long")
2020-07-01 14:33:59 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("SectorType"))); err != nil {
2020-07-01 14:33:59 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("SectorType")); err != nil {
2020-07-01 14:33:59 +00:00
return err
}
if t.SectorType >= 0 {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorType)); err != nil {
return err
}
} else {
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.SectorType-1)); err != nil {
return err
}
2020-07-01 14:33:59 +00:00
}
// t.TicketEpoch (abi.ChainEpoch) (int64)
if len("TicketEpoch") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"TicketEpoch\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("TicketEpoch"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("TicketEpoch")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if t.TicketEpoch >= 0 {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.TicketEpoch)); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
} else {
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.TicketEpoch-1)); err != nil {
return err
2020-04-06 20:35:29 +00:00
}
}
// t.TicketValue (abi.SealRandomness) (slice)
if len("TicketValue") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"TicketValue\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("TicketValue"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("TicketValue")); err != nil {
return err
}
if len(t.TicketValue) > cbg.ByteArrayMaxLen {
return xerrors.Errorf("Byte array in field t.TicketValue was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajByteString, uint64(len(t.TicketValue))); err != nil {
return err
}
if _, err := cw.Write(t.TicketValue[:]); err != nil {
return err
}
// t.CreationTime (int64) (int64)
if len("CreationTime") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"CreationTime\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("CreationTime"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("CreationTime")); err != nil {
return err
}
if t.CreationTime >= 0 {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.CreationTime)); err != nil {
return err
}
} else {
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.CreationTime-1)); err != nil {
return err
}
}
// t.SectorNumber (abi.SectorNumber) (uint64)
if len("SectorNumber") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"SectorNumber\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("SectorNumber"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("SectorNumber")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorNumber)); err != nil {
return err
2020-04-06 20:35:29 +00:00
}
// t.TerminatedAt (abi.ChainEpoch) (int64)
if len("TerminatedAt") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"TerminatedAt\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("TerminatedAt"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("TerminatedAt")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if t.TerminatedAt >= 0 {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.TerminatedAt)); err != nil {
return err
}
} else {
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.TerminatedAt-1)); err != nil {
return err
}
2020-04-06 20:35:29 +00:00
}
// t.UpdateSealed (cid.Cid) (struct)
if len("UpdateSealed") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"UpdateSealed\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("UpdateSealed"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("UpdateSealed")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if t.UpdateSealed == nil {
if _, err := cw.Write(cbg.CborNull); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
} else {
if err := cbg.WriteCid(cw, *t.UpdateSealed); err != nil {
return xerrors.Errorf("failed to write cid field t.UpdateSealed: %w", err)
2020-04-06 20:35:29 +00:00
}
}
// t.CommitMessage (cid.Cid) (struct)
if len("CommitMessage") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"CommitMessage\" was too long")
}
2022-04-20 21:34:28 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("CommitMessage"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("CommitMessage")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if t.CommitMessage == nil {
2022-04-20 21:34:28 +00:00
if _, err := cw.Write(cbg.CborNull); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
} else {
2022-04-20 21:34:28 +00:00
if err := cbg.WriteCid(cw, *t.CommitMessage); err != nil {
2020-04-06 20:35:29 +00:00
return xerrors.Errorf("failed to write cid field t.CommitMessage: %w", err)
}
}
// t.InvalidProofs (uint64) (uint64)
if len("InvalidProofs") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"InvalidProofs\" was too long")
}
2022-04-20 21:34:28 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("InvalidProofs"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("InvalidProofs")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2022-04-20 21:34:28 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.InvalidProofs)); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
// t.PreCommit1Out (storiface.PreCommit1Out) (slice)
if len("PreCommit1Out") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"PreCommit1Out\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("PreCommit1Out"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("PreCommit1Out")); err != nil {
return err
}
if len(t.PreCommit1Out) > cbg.ByteArrayMaxLen {
return xerrors.Errorf("Byte array in field t.PreCommit1Out was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajByteString, uint64(len(t.PreCommit1Out))); err != nil {
return err
}
if _, err := cw.Write(t.PreCommit1Out[:]); err != nil {
return err
}
// t.FaultReportMsg (cid.Cid) (struct)
if len("FaultReportMsg") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"FaultReportMsg\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("FaultReportMsg"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("FaultReportMsg")); err != nil {
return err
}
if t.FaultReportMsg == nil {
2022-04-20 21:34:28 +00:00
if _, err := cw.Write(cbg.CborNull); err != nil {
return err
}
} else {
if err := cbg.WriteCid(cw, *t.FaultReportMsg); err != nil {
return xerrors.Errorf("failed to write cid field t.FaultReportMsg: %w", err)
}
}
// t.UpdateUnsealed (cid.Cid) (struct)
if len("UpdateUnsealed") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"UpdateUnsealed\" was too long")
}
2022-04-20 21:34:28 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("UpdateUnsealed"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("UpdateUnsealed")); err != nil {
return err
}
if t.UpdateUnsealed == nil {
2022-04-20 21:34:28 +00:00
if _, err := cw.Write(cbg.CborNull); err != nil {
return err
}
} else {
2022-04-20 21:34:28 +00:00
if err := cbg.WriteCid(cw, *t.UpdateUnsealed); err != nil {
return xerrors.Errorf("failed to write cid field t.UpdateUnsealed: %w", err)
}
}
2023-07-18 18:55:14 +00:00
// t.PreCommit1Fails (uint64) (uint64)
if len("PreCommit1Fails") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"PreCommit1Fails\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("PreCommit1Fails"))); err != nil {
return err
}
if _, err := cw.WriteString(string("PreCommit1Fails")); err != nil {
2023-07-18 18:55:14 +00:00
return err
}
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.PreCommit1Fails)); err != nil {
return err
}
// t.PreCommit2Fails (uint64) (uint64)
if len("PreCommit2Fails") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"PreCommit2Fails\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("PreCommit2Fails"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("PreCommit2Fails")); err != nil {
return err
}
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.PreCommit2Fails)); err != nil {
return err
}
// t.PreCommitTipSet (types.TipSetKey) (struct)
if len("PreCommitTipSet") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"PreCommitTipSet\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("PreCommitTipSet"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("PreCommitTipSet")); err != nil {
return err
}
if err := t.PreCommitTipSet.MarshalCBOR(cw); err != nil {
return err
}
// t.RemoteDataCache (storiface.SectorLocation) (struct)
if len("RemoteDataCache") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"RemoteDataCache\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("RemoteDataCache"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("RemoteDataCache")); err != nil {
return err
}
if err := t.RemoteDataCache.MarshalCBOR(cw); err != nil {
return err
}
// t.PreCommitDeposit (big.Int) (struct)
if len("PreCommitDeposit") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"PreCommitDeposit\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("PreCommitDeposit"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("PreCommitDeposit")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if err := t.PreCommitDeposit.MarshalCBOR(cw); err != nil {
return err
}
// t.PreCommitMessage (cid.Cid) (struct)
if len("PreCommitMessage") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"PreCommitMessage\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("PreCommitMessage"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("PreCommitMessage")); err != nil {
return err
}
if t.PreCommitMessage == nil {
2022-04-20 21:34:28 +00:00
if _, err := cw.Write(cbg.CborNull); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
} else {
if err := cbg.WriteCid(cw, *t.PreCommitMessage); err != nil {
return xerrors.Errorf("failed to write cid field t.PreCommitMessage: %w", err)
2020-04-06 20:35:29 +00:00
}
}
// t.RemoteDataSealed (storiface.SectorLocation) (struct)
if len("RemoteDataSealed") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"RemoteDataSealed\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("RemoteDataSealed"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("RemoteDataSealed")); err != nil {
return err
}
if err := t.RemoteDataSealed.MarshalCBOR(cw); err != nil {
return err
}
2021-01-12 23:42:01 +00:00
// t.TerminateMessage (cid.Cid) (struct)
if len("TerminateMessage") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"TerminateMessage\" was too long")
}
2022-04-20 21:34:28 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("TerminateMessage"))); err != nil {
2021-01-12 23:42:01 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("TerminateMessage")); err != nil {
2021-01-12 23:42:01 +00:00
return err
}
if t.TerminateMessage == nil {
2022-04-20 21:34:28 +00:00
if _, err := cw.Write(cbg.CborNull); err != nil {
2021-01-12 23:42:01 +00:00
return err
}
} else {
2022-04-20 21:34:28 +00:00
if err := cbg.WriteCid(cw, *t.TerminateMessage); err != nil {
2021-01-12 23:42:01 +00:00
return xerrors.Errorf("failed to write cid field t.TerminateMessage: %w", err)
}
}
2022-09-16 21:45:23 +00:00
// t.RemoteDataUnsealed (storiface.SectorLocation) (struct)
2022-09-02 15:12:58 +00:00
if len("RemoteDataUnsealed") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"RemoteDataUnsealed\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("RemoteDataUnsealed"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("RemoteDataUnsealed")); err != nil {
2022-09-02 15:12:58 +00:00
return err
}
if err := t.RemoteDataUnsealed.MarshalCBOR(cw); err != nil {
return err
}
// t.ReplicaUpdateProof (storiface.ReplicaUpdateProof) (slice)
if len("ReplicaUpdateProof") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"ReplicaUpdateProof\" was too long")
2022-09-02 15:12:58 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("ReplicaUpdateProof"))); err != nil {
2022-09-02 15:12:58 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("ReplicaUpdateProof")); err != nil {
2022-09-02 15:12:58 +00:00
return err
}
if len(t.ReplicaUpdateProof) > cbg.ByteArrayMaxLen {
return xerrors.Errorf("Byte array in field t.ReplicaUpdateProof was too long")
2022-09-02 15:12:58 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajByteString, uint64(len(t.ReplicaUpdateProof))); err != nil {
2022-09-02 15:12:58 +00:00
return err
}
if _, err := cw.Write(t.ReplicaUpdateProof[:]); err != nil {
2022-09-09 08:32:27 +00:00
return err
}
// t.RemoteDataFinalized (bool) (bool)
if len("RemoteDataFinalized") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"RemoteDataFinalized\" was too long")
2022-09-09 08:32:27 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("RemoteDataFinalized"))); err != nil {
2022-09-09 08:32:27 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("RemoteDataFinalized")); err != nil {
2022-09-09 08:32:27 +00:00
return err
}
if err := cbg.WriteBool(w, t.RemoteDataFinalized); err != nil {
2022-09-09 10:54:48 +00:00
return err
}
// t.ReplicaUpdateMessage (cid.Cid) (struct)
if len("ReplicaUpdateMessage") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"ReplicaUpdateMessage\" was too long")
2022-09-09 10:54:48 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("ReplicaUpdateMessage"))); err != nil {
2022-09-09 10:54:48 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("ReplicaUpdateMessage")); err != nil {
2022-09-09 10:54:48 +00:00
return err
}
if t.ReplicaUpdateMessage == nil {
if _, err := cw.Write(cbg.CborNull); err != nil {
return err
}
} else {
if err := cbg.WriteCid(cw, *t.ReplicaUpdateMessage); err != nil {
return xerrors.Errorf("failed to write cid field t.ReplicaUpdateMessage: %w", err)
}
}
// t.RemoteCommit1Endpoint (string) (string)
if len("RemoteCommit1Endpoint") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"RemoteCommit1Endpoint\" was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("RemoteCommit1Endpoint"))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("RemoteCommit1Endpoint")); err != nil {
return err
}
if len(t.RemoteCommit1Endpoint) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.RemoteCommit1Endpoint was too long")
2022-09-02 15:12:58 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RemoteCommit1Endpoint))); err != nil {
2022-09-02 15:12:58 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.RemoteCommit1Endpoint)); err != nil {
2022-09-02 15:12:58 +00:00
return err
}
// t.RemoteCommit2Endpoint (string) (string)
if len("RemoteCommit2Endpoint") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"RemoteCommit2Endpoint\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("RemoteCommit2Endpoint"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("RemoteCommit2Endpoint")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if len(t.RemoteCommit2Endpoint) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.RemoteCommit2Endpoint was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RemoteCommit2Endpoint))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.RemoteCommit2Endpoint)); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
// t.RemoteSealingDoneEndpoint (string) (string)
if len("RemoteSealingDoneEndpoint") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"RemoteSealingDoneEndpoint\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("RemoteSealingDoneEndpoint"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("RemoteSealingDoneEndpoint")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if len(t.RemoteSealingDoneEndpoint) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.RemoteSealingDoneEndpoint was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RemoteSealingDoneEndpoint))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.RemoteSealingDoneEndpoint)); err != nil {
return err
2020-04-06 20:35:29 +00:00
}
2020-01-22 02:41:39 +00:00
return nil
2020-04-06 20:35:29 +00:00
}
2022-04-20 21:34:28 +00:00
func (t *SectorInfo) UnmarshalCBOR(r io.Reader) (err error) {
*t = SectorInfo{}
2022-04-20 21:34:28 +00:00
cr := cbg.NewCborReader(r)
2020-04-06 20:35:29 +00:00
2022-04-20 21:34:28 +00:00
maj, extra, err := cr.ReadHeader()
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
2022-04-20 21:34:28 +00:00
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
2020-04-06 20:35:29 +00:00
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
}
if extra > cbg.MaxLength {
return fmt.Errorf("SectorInfo: map struct too large (%d)", extra)
}
2020-04-06 20:23:37 +00:00
2020-04-06 20:35:29 +00:00
var name string
n := extra
for i := uint64(0); i < n; i++ {
{
2022-04-20 21:34:28 +00:00
sval, err := cbg.ReadString(cr)
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
name = string(sval)
}
switch name {
// t.Log ([]sealing.Log) (slice)
case "Log":
2020-04-06 20:35:29 +00:00
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
if extra > cbg.MaxLength {
return fmt.Errorf("t.Log: array too large (%d)", extra)
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.Log = make([]Log, 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
2023-09-23 21:21:22 +00:00
{
2020-04-06 20:35:29 +00:00
2023-09-23 21:21:22 +00:00
if err := t.Log[i].UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.Log[i]: %w", err)
}
}
}
2020-04-06 20:35:29 +00:00
}
// t.CommD (cid.Cid) (struct)
case "CommD":
2020-04-06 20:35:29 +00:00
{
b, err := cr.ReadByte()
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
if b != cbg.CborNull[0] {
if err := cr.UnreadByte(); err != nil {
return err
}
c, err := cbg.ReadCid(cr)
if err != nil {
return xerrors.Errorf("failed to read cid field t.CommD: %w", err)
}
t.CommD = &c
2020-04-06 20:35:29 +00:00
}
}
// t.CommR (cid.Cid) (struct)
case "CommR":
2020-04-06 20:35:29 +00:00
{
b, err := cr.ReadByte()
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
if b != cbg.CborNull[0] {
if err := cr.UnreadByte(); err != nil {
return err
2020-04-06 20:35:29 +00:00
}
c, err := cbg.ReadCid(cr)
if err != nil {
return xerrors.Errorf("failed to read cid field t.CommR: %w", err)
2020-04-06 20:35:29 +00:00
}
t.CommR = &c
2020-04-06 20:35:29 +00:00
}
}
// t.Proof ([]uint8) (slice)
case "Proof":
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Proof: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
if extra > 0 {
t.Proof = make([]uint8, extra)
}
if _, err := io.ReadFull(cr, t.Proof[:]); err != nil {
return err
}
// t.State (sealing.SectorState) (string)
case "State":
2021-01-18 21:05:56 +00:00
{
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
2021-01-18 21:05:56 +00:00
t.State = SectorState(sval)
2021-01-18 21:05:56 +00:00
}
2022-08-26 00:37:36 +00:00
// t.Pieces ([]api.SectorPiece) (slice)
case "Pieces":
2020-04-06 20:35:29 +00:00
2022-04-20 21:34:28 +00:00
maj, extra, err = cr.ReadHeader()
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
if extra > cbg.MaxLength {
return fmt.Errorf("t.Pieces: array too large (%d)", extra)
2020-04-06 20:35:29 +00:00
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
2020-04-06 20:35:29 +00:00
if extra > 0 {
2022-08-26 00:37:36 +00:00
t.Pieces = make([]api.SectorPiece, extra)
2020-04-06 20:35:29 +00:00
}
2020-04-06 20:35:29 +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
2020-04-06 20:35:29 +00:00
2023-09-23 21:21:22 +00:00
{
if err := t.Pieces[i].UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.Pieces[i]: %w", err)
}
2020-04-06 20:35:29 +00:00
2023-09-23 21:21:22 +00:00
}
}
2020-04-06 20:35:29 +00:00
}
// t.Return (sealing.ReturnState) (string)
case "Return":
{
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
t.Return = ReturnState(sval)
}
// t.LastErr (string) (string)
case "LastErr":
{
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
t.LastErr = string(sval)
}
// t.CCPieces ([]api.SectorPiece) (slice)
case "CCPieces":
2020-04-06 20:35:29 +00:00
2022-04-20 21:34:28 +00:00
maj, extra, err = cr.ReadHeader()
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
if extra > cbg.MaxLength {
return fmt.Errorf("t.CCPieces: array too large (%d)", extra)
2020-04-06 20:35:29 +00:00
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
2020-04-06 20:35:29 +00:00
}
if extra > 0 {
t.CCPieces = make([]api.SectorPiece, 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
2023-09-23 21:21:22 +00:00
{
2023-09-23 21:21:22 +00:00
if err := t.CCPieces[i].UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.CCPieces[i]: %w", err)
}
}
}
}
// t.CCUpdate (bool) (bool)
case "CCUpdate":
maj, extra, err = cr.ReadHeader()
if err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if maj != cbg.MajOther {
return fmt.Errorf("booleans must be major type 7")
}
switch extra {
case 20:
t.CCUpdate = false
case 21:
t.CCUpdate = true
default:
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
}
// t.SeedEpoch (abi.ChainEpoch) (int64)
case "SeedEpoch":
2020-04-06 20:35:29 +00:00
{
2022-04-20 21:34:28 +00:00
maj, extra, err := cr.ReadHeader()
2020-04-06 20:35:29 +00:00
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 overflow")
2020-04-06 20:35:29 +00:00
}
extraI = -1 - extraI
default:
return fmt.Errorf("wrong type for int64 field: %d", maj)
}
t.SeedEpoch = abi.ChainEpoch(extraI)
2020-04-06 20:35:29 +00:00
}
// t.SeedValue (abi.InteractiveSealRandomness) (slice)
case "SeedValue":
2020-04-06 20:35:29 +00:00
2022-04-20 21:34:28 +00:00
maj, extra, err = cr.ReadHeader()
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.SeedValue: byte array too large (%d)", extra)
2020-04-06 20:35:29 +00:00
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
if extra > 0 {
t.SeedValue = make([]uint8, extra)
}
if _, err := io.ReadFull(cr, t.SeedValue[:]); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
// t.SectorType (abi.RegisteredSealProof) (int64)
case "SectorType":
2020-04-06 20:35:29 +00:00
{
maj, extra, err := cr.ReadHeader()
var extraI int64
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
switch maj {
case cbg.MajUnsignedInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 positive overflow")
2020-04-06 20:35:29 +00:00
}
case cbg.MajNegativeInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 negative overflow")
2020-04-06 20:35:29 +00:00
}
extraI = -1 - extraI
default:
return fmt.Errorf("wrong type for int64 field: %d", maj)
2020-04-06 20:35:29 +00:00
}
t.SectorType = abi.RegisteredSealProof(extraI)
2020-04-06 20:35:29 +00:00
}
// t.TicketEpoch (abi.ChainEpoch) (int64)
case "TicketEpoch":
2020-04-06 20:35:29 +00:00
{
maj, extra, err := cr.ReadHeader()
var extraI int64
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
switch maj {
case cbg.MajUnsignedInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 positive overflow")
2020-04-06 20:35:29 +00:00
}
case cbg.MajNegativeInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 negative overflow")
2020-04-06 20:35:29 +00:00
}
extraI = -1 - extraI
default:
return fmt.Errorf("wrong type for int64 field: %d", maj)
2020-04-06 20:35:29 +00:00
}
t.TicketEpoch = abi.ChainEpoch(extraI)
2020-04-06 20:35:29 +00:00
}
// t.TicketValue (abi.SealRandomness) (slice)
case "TicketValue":
2020-04-06 20:35:29 +00:00
2022-04-20 21:34:28 +00:00
maj, extra, err = cr.ReadHeader()
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.TicketValue: byte array too large (%d)", extra)
2020-04-06 20:35:29 +00:00
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
if extra > 0 {
t.TicketValue = make([]uint8, extra)
}
if _, err := io.ReadFull(cr, t.TicketValue[:]); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
// t.CreationTime (int64) (int64)
case "CreationTime":
2020-04-06 20:35:29 +00:00
{
maj, extra, err := cr.ReadHeader()
var extraI int64
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
switch maj {
case cbg.MajUnsignedInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 positive overflow")
2020-04-06 20:35:29 +00:00
}
case cbg.MajNegativeInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 negative overflow")
2020-04-06 20:35:29 +00:00
}
extraI = -1 - extraI
default:
return fmt.Errorf("wrong type for int64 field: %d", maj)
}
t.CreationTime = int64(extraI)
}
// t.SectorNumber (abi.SectorNumber) (uint64)
case "SectorNumber":
{
2022-04-20 21:34:28 +00:00
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.SectorNumber = abi.SectorNumber(extra)
2020-04-06 20:35:29 +00:00
}
// t.TerminatedAt (abi.ChainEpoch) (int64)
case "TerminatedAt":
2020-04-06 20:35:29 +00:00
{
2022-04-20 21:34:28 +00:00
maj, extra, err := cr.ReadHeader()
2020-04-06 20:35:29 +00:00
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 overflow")
2020-04-06 20:35:29 +00:00
}
extraI = -1 - extraI
default:
return fmt.Errorf("wrong type for int64 field: %d", maj)
}
t.TerminatedAt = abi.ChainEpoch(extraI)
}
// t.UpdateSealed (cid.Cid) (struct)
case "UpdateSealed":
{
b, err := cr.ReadByte()
if err != nil {
return err
}
if b != cbg.CborNull[0] {
if err := cr.UnreadByte(); err != nil {
return err
}
c, err := cbg.ReadCid(cr)
if err != nil {
return xerrors.Errorf("failed to read cid field t.UpdateSealed: %w", err)
}
t.UpdateSealed = &c
}
2020-04-06 20:35:29 +00:00
}
// t.CommitMessage (cid.Cid) (struct)
case "CommitMessage":
{
2022-04-20 21:34:28 +00:00
b, err := cr.ReadByte()
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
if b != cbg.CborNull[0] {
2022-04-20 21:34:28 +00:00
if err := cr.UnreadByte(); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2022-04-20 21:34:28 +00:00
c, err := cbg.ReadCid(cr)
2020-04-06 20:35:29 +00:00
if err != nil {
return xerrors.Errorf("failed to read cid field t.CommitMessage: %w", err)
}
t.CommitMessage = &c
}
}
// t.InvalidProofs (uint64) (uint64)
case "InvalidProofs":
{
2022-04-20 21:34:28 +00:00
maj, extra, err = cr.ReadHeader()
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.InvalidProofs = uint64(extra)
}
// t.PreCommit1Out (storiface.PreCommit1Out) (slice)
case "PreCommit1Out":
2022-04-20 21:34:28 +00:00
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.PreCommit1Out: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
if extra > 0 {
t.PreCommit1Out = make([]uint8, extra)
}
if _, err := io.ReadFull(cr, t.PreCommit1Out[:]); err != nil {
return err
}
// t.FaultReportMsg (cid.Cid) (struct)
case "FaultReportMsg":
{
2022-04-20 21:34:28 +00:00
b, err := cr.ReadByte()
if err != nil {
return err
}
if b != cbg.CborNull[0] {
2022-04-20 21:34:28 +00:00
if err := cr.UnreadByte(); err != nil {
return err
}
2022-04-20 21:34:28 +00:00
c, err := cbg.ReadCid(cr)
if err != nil {
return xerrors.Errorf("failed to read cid field t.FaultReportMsg: %w", err)
}
t.FaultReportMsg = &c
}
}
// t.UpdateUnsealed (cid.Cid) (struct)
case "UpdateUnsealed":
{
2022-04-20 21:34:28 +00:00
b, err := cr.ReadByte()
if err != nil {
return err
}
if b != cbg.CborNull[0] {
2022-04-20 21:34:28 +00:00
if err := cr.UnreadByte(); err != nil {
return err
}
2022-04-20 21:34:28 +00:00
c, err := cbg.ReadCid(cr)
if err != nil {
return xerrors.Errorf("failed to read cid field t.UpdateUnsealed: %w", err)
}
t.UpdateUnsealed = &c
}
2023-07-18 18:55:14 +00:00
}
// t.PreCommit1Fails (uint64) (uint64)
case "PreCommit1Fails":
{
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.PreCommit1Fails = uint64(extra)
}
// t.PreCommit2Fails (uint64) (uint64)
case "PreCommit2Fails":
{
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.PreCommit2Fails = uint64(extra)
}
// t.PreCommitTipSet (types.TipSetKey) (struct)
case "PreCommitTipSet":
{
if err := t.PreCommitTipSet.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.PreCommitTipSet: %w", err)
}
}
// t.RemoteDataCache (storiface.SectorLocation) (struct)
case "RemoteDataCache":
{
2022-04-20 21:34:28 +00:00
b, err := cr.ReadByte()
if err != nil {
return err
}
if b != cbg.CborNull[0] {
2022-04-20 21:34:28 +00:00
if err := cr.UnreadByte(); err != nil {
return err
}
t.RemoteDataCache = new(storiface.SectorLocation)
if err := t.RemoteDataCache.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.RemoteDataCache pointer: %w", err)
}
}
}
// t.PreCommitDeposit (big.Int) (struct)
case "PreCommitDeposit":
{
if err := t.PreCommitDeposit.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.PreCommitDeposit: %w", err)
}
2020-04-06 20:35:29 +00:00
}
// t.PreCommitMessage (cid.Cid) (struct)
case "PreCommitMessage":
2020-04-06 20:35:29 +00:00
{
2022-04-20 21:34:28 +00:00
b, err := cr.ReadByte()
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
if b != cbg.CborNull[0] {
2022-04-20 21:34:28 +00:00
if err := cr.UnreadByte(); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2022-04-20 21:34:28 +00:00
c, err := cbg.ReadCid(cr)
2020-04-06 20:35:29 +00:00
if err != nil {
return xerrors.Errorf("failed to read cid field t.PreCommitMessage: %w", err)
2020-04-06 20:35:29 +00:00
}
t.PreCommitMessage = &c
2020-04-06 20:35:29 +00:00
}
}
// t.RemoteDataSealed (storiface.SectorLocation) (struct)
case "RemoteDataSealed":
{
b, err := cr.ReadByte()
if err != nil {
return err
}
if b != cbg.CborNull[0] {
if err := cr.UnreadByte(); err != nil {
return err
}
t.RemoteDataSealed = new(storiface.SectorLocation)
if err := t.RemoteDataSealed.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.RemoteDataSealed pointer: %w", err)
}
}
}
2021-01-12 23:42:01 +00:00
// t.TerminateMessage (cid.Cid) (struct)
case "TerminateMessage":
{
2022-04-20 21:34:28 +00:00
b, err := cr.ReadByte()
2021-01-12 23:42:01 +00:00
if err != nil {
return err
}
if b != cbg.CborNull[0] {
2022-04-20 21:34:28 +00:00
if err := cr.UnreadByte(); err != nil {
2021-01-12 23:42:01 +00:00
return err
}
2022-04-20 21:34:28 +00:00
c, err := cbg.ReadCid(cr)
2021-01-12 23:42:01 +00:00
if err != nil {
return xerrors.Errorf("failed to read cid field t.TerminateMessage: %w", err)
}
t.TerminateMessage = &c
}
}
2022-09-16 21:45:23 +00:00
// t.RemoteDataUnsealed (storiface.SectorLocation) (struct)
2022-09-02 15:12:58 +00:00
case "RemoteDataUnsealed":
{
b, err := cr.ReadByte()
if err != nil {
return err
}
if b != cbg.CborNull[0] {
if err := cr.UnreadByte(); err != nil {
return err
}
2022-09-16 21:45:23 +00:00
t.RemoteDataUnsealed = new(storiface.SectorLocation)
2022-09-02 15:12:58 +00:00
if err := t.RemoteDataUnsealed.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.RemoteDataUnsealed pointer: %w", err)
}
}
}
// t.ReplicaUpdateProof (storiface.ReplicaUpdateProof) (slice)
case "ReplicaUpdateProof":
2022-09-02 15:12:58 +00:00
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
2022-09-02 15:12:58 +00:00
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.ReplicaUpdateProof: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
if extra > 0 {
t.ReplicaUpdateProof = make([]uint8, extra)
}
2022-09-02 15:12:58 +00:00
if _, err := io.ReadFull(cr, t.ReplicaUpdateProof[:]); err != nil {
return err
2022-09-02 15:12:58 +00:00
}
// t.RemoteDataFinalized (bool) (bool)
case "RemoteDataFinalized":
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
if maj != cbg.MajOther {
return fmt.Errorf("booleans must be major type 7")
}
switch extra {
case 20:
t.RemoteDataFinalized = false
case 21:
t.RemoteDataFinalized = true
default:
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
}
// t.ReplicaUpdateMessage (cid.Cid) (struct)
case "ReplicaUpdateMessage":
2022-09-02 15:12:58 +00:00
{
b, err := cr.ReadByte()
if err != nil {
return err
}
if b != cbg.CborNull[0] {
if err := cr.UnreadByte(); err != nil {
return err
}
c, err := cbg.ReadCid(cr)
if err != nil {
return xerrors.Errorf("failed to read cid field t.ReplicaUpdateMessage: %w", err)
2022-09-02 15:12:58 +00:00
}
t.ReplicaUpdateMessage = &c
2022-09-02 15:12:58 +00:00
}
}
2022-09-09 08:32:27 +00:00
// t.RemoteCommit1Endpoint (string) (string)
case "RemoteCommit1Endpoint":
{
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
t.RemoteCommit1Endpoint = string(sval)
}
2022-09-09 10:54:48 +00:00
// t.RemoteCommit2Endpoint (string) (string)
case "RemoteCommit2Endpoint":
{
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
t.RemoteCommit2Endpoint = string(sval)
}
// t.RemoteSealingDoneEndpoint (string) (string)
case "RemoteSealingDoneEndpoint":
{
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
t.RemoteSealingDoneEndpoint = string(sval)
}
2020-04-06 20:35:29 +00:00
default:
// Field doesn't exist on this type, so ignore it
cbg.ScanForLinks(r, func(cid.Cid) {})
2020-04-06 20:35:29 +00:00
}
}
return nil
2020-01-22 02:41:39 +00:00
}
func (t *Log) MarshalCBOR(w io.Writer) error {
2020-04-06 20:35:29 +00:00
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
2022-04-20 21:34:28 +00:00
cw := cbg.NewCborWriter(w)
if _, err := cw.Write([]byte{164}); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
// t.Kind (string) (string)
if len("Kind") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Kind\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Kind"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Kind")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if len(t.Kind) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.Kind was too long")
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Kind))); err != nil {
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.Kind)); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
// t.Trace (string) (string)
if len("Trace") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Trace\" was too long")
}
2022-04-20 21:34:28 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Trace"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Trace")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if len(t.Trace) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.Trace was too long")
}
2022-04-20 21:34:28 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Trace))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.Trace)); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
// t.Message (string) (string)
if len("Message") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Message\" was too long")
}
2022-04-20 21:34:28 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Message"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Message")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if len(t.Message) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.Message was too long")
}
2022-04-20 21:34:28 +00:00
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Message))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string(t.Message)); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
// t.Timestamp (uint64) (uint64)
if len("Timestamp") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Timestamp\" was too long")
2020-04-06 20:35:29 +00:00
}
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Timestamp"))); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2023-09-23 21:21:22 +00:00
if _, err := cw.WriteString(string("Timestamp")); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Timestamp)); err != nil {
2020-04-06 20:35:29 +00:00
return err
}
2020-01-22 02:41:39 +00:00
return nil
}
2022-04-20 21:34:28 +00:00
func (t *Log) UnmarshalCBOR(r io.Reader) (err error) {
*t = Log{}
2022-04-20 21:34:28 +00:00
cr := cbg.NewCborReader(r)
2020-04-06 20:35:29 +00:00
2022-04-20 21:34:28 +00:00
maj, extra, err := cr.ReadHeader()
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
2022-04-20 21:34:28 +00:00
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
2020-04-06 20:35:29 +00:00
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
}
if extra > cbg.MaxLength {
return fmt.Errorf("Log: map struct too large (%d)", extra)
}
var name string
n := extra
for i := uint64(0); i < n; i++ {
{
2022-04-20 21:34:28 +00:00
sval, err := cbg.ReadString(cr)
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
name = string(sval)
}
2020-04-06 20:23:37 +00:00
2020-04-06 20:35:29 +00:00
switch name {
// t.Kind (string) (string)
case "Kind":
2020-04-06 20:35:29 +00:00
{
sval, err := cbg.ReadString(cr)
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
t.Kind = string(sval)
2020-04-06 20:35:29 +00:00
}
// t.Trace (string) (string)
case "Trace":
{
2022-04-20 21:34:28 +00:00
sval, err := cbg.ReadString(cr)
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
t.Trace = string(sval)
}
// t.Message (string) (string)
case "Message":
{
2022-04-20 21:34:28 +00:00
sval, err := cbg.ReadString(cr)
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
t.Message = string(sval)
}
// t.Timestamp (uint64) (uint64)
case "Timestamp":
2020-04-06 20:35:29 +00:00
{
maj, extra, err = cr.ReadHeader()
2020-04-06 20:35:29 +00:00
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.Timestamp = uint64(extra)
2020-04-06 20:35:29 +00:00
}
default:
// Field doesn't exist on this type, so ignore it
cbg.ScanForLinks(r, func(cid.Cid) {})
2020-04-06 20:35:29 +00:00
}
}
return nil
}