2019-11-01 13:58:48 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2019-11-05 18:02:28 +00:00
|
|
|
"io"
|
|
|
|
|
2019-11-01 13:58:48 +00:00
|
|
|
cbg "github.com/whyrusleeping/cbor-gen"
|
|
|
|
xerrors "golang.org/x/xerrors"
|
|
|
|
)
|
|
|
|
|
|
|
|
/* This file was generated by github.com/whyrusleeping/cbor-gen */
|
|
|
|
|
|
|
|
var _ = xerrors.Errorf
|
|
|
|
|
|
|
|
func (t *SealTicket) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
if _, err := w.Write([]byte{162}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.BlockHeight (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("BlockHeight")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("BlockHeight")); err != nil {
|
2019-11-01 13:58:48 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 18:02:28 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.BlockHeight))); err != nil {
|
2019-11-01 13:58:48 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.TicketBytes ([]uint8) (slice)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("TicketBytes")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("TicketBytes")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-01 13:58:48 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.TicketBytes)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write(t.TicketBytes); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *SealTicket) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
if maj != cbg.MajMap {
|
|
|
|
return fmt.Errorf("cbor input should be of type map")
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 2 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
var name string
|
|
|
|
|
|
|
|
// t.BlockHeight (uint64) (uint64)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "BlockHeight" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be BlockHeight", name)
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
2019-11-05 18:02:28 +00:00
|
|
|
t.BlockHeight = uint64(extra)
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.TicketBytes ([]uint8) (slice)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "TicketBytes" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be TicketBytes", name)
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
if extra > cbg.ByteArrayMaxLen {
|
|
|
|
return fmt.Errorf("t.TicketBytes: byte array too large (%d)", extra)
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
if maj != cbg.MajByteString {
|
|
|
|
return fmt.Errorf("expected byte array")
|
|
|
|
}
|
|
|
|
t.TicketBytes = make([]byte, extra)
|
|
|
|
if _, err := io.ReadFull(br, t.TicketBytes); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-11-08 18:15:13 +00:00
|
|
|
func (t *SealSeed) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
if _, err := w.Write([]byte{162}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.BlockHeight (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("BlockHeight")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("BlockHeight")); err != nil {
|
2019-11-08 18:15:13 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.BlockHeight))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.TicketBytes ([]uint8) (slice)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("TicketBytes")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("TicketBytes")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-08 18:15:13 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.TicketBytes)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write(t.TicketBytes); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *SealSeed) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
if maj != cbg.MajMap {
|
|
|
|
return fmt.Errorf("cbor input should be of type map")
|
2019-11-08 18:15:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 2 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
var name string
|
|
|
|
|
|
|
|
// t.BlockHeight (uint64) (uint64)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "BlockHeight" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be BlockHeight", name)
|
|
|
|
}
|
2019-11-08 18:15:13 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
|
|
|
t.BlockHeight = uint64(extra)
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.TicketBytes ([]uint8) (slice)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "TicketBytes" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be TicketBytes", name)
|
|
|
|
}
|
2019-11-08 18:15:13 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
if extra > cbg.ByteArrayMaxLen {
|
|
|
|
return fmt.Errorf("t.TicketBytes: byte array too large (%d)", extra)
|
|
|
|
}
|
2019-11-08 18:15:13 +00:00
|
|
|
if maj != cbg.MajByteString {
|
|
|
|
return fmt.Errorf("expected byte array")
|
|
|
|
}
|
|
|
|
t.TicketBytes = make([]byte, extra)
|
|
|
|
if _, err := io.ReadFull(br, t.TicketBytes); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-11-07 18:27:23 +00:00
|
|
|
func (t *Piece) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
if _, err := w.Write([]byte{163}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.DealID (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("DealID")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("DealID")); err != nil {
|
2019-11-07 18:27:23 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.DealID))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Size (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Size")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("Size")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-07 18:27:23 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Size))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.CommP ([]uint8) (slice)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("CommP")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("CommP")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-07 18:27:23 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.CommP)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write(t.CommP); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Piece) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
if maj != cbg.MajMap {
|
|
|
|
return fmt.Errorf("cbor input should be of type map")
|
2019-11-07 18:27:23 +00:00
|
|
|
}
|
|
|
|
|
2019-12-01 17:58:31 +00:00
|
|
|
if extra != 3 {
|
2019-11-07 18:27:23 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
var name string
|
|
|
|
|
|
|
|
// t.DealID (uint64) (uint64)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "DealID" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be DealID", name)
|
|
|
|
}
|
2019-11-07 18:27:23 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
|
|
|
t.DealID = uint64(extra)
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Size (uint64) (uint64)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "Size" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be Size", name)
|
|
|
|
}
|
2019-11-07 18:27:23 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
|
|
|
t.Size = uint64(extra)
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.CommP ([]uint8) (slice)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "CommP" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be CommP", name)
|
|
|
|
}
|
2019-11-07 18:27:23 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
if extra > cbg.ByteArrayMaxLen {
|
|
|
|
return fmt.Errorf("t.CommP: byte array too large (%d)", extra)
|
|
|
|
}
|
2019-11-07 18:27:23 +00:00
|
|
|
if maj != cbg.MajByteString {
|
|
|
|
return fmt.Errorf("expected byte array")
|
|
|
|
}
|
|
|
|
t.CommP = make([]byte, extra)
|
|
|
|
if _, err := io.ReadFull(br, t.CommP); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-11-01 13:58:48 +00:00
|
|
|
func (t *SectorInfo) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 20:27:20 +00:00
|
|
|
if _, err := w.Write([]byte{173}); err != nil {
|
2019-12-09 16:40:15 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.State (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("State")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("State")); err != nil {
|
2019-11-01 13:58:48 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 18:02:28 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.State))); err != nil {
|
2019-11-01 13:58:48 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.SectorID (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("SectorID")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("SectorID")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 18:02:28 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorID))); err != nil {
|
2019-11-01 13:58:48 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Nonce (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Nonce")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("Nonce")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-08 16:10:45 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Nonce))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Pieces ([]storage.Piece) (slice)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Pieces")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("Pieces")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-07 18:27:23 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Pieces)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.Pieces {
|
|
|
|
if err := v.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.CommD ([]uint8) (slice)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("CommD")))); err != nil {
|
2019-11-07 18:27:23 +00:00
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
if _, err := w.Write([]byte("CommD")); err != nil {
|
2019-11-07 18:27:23 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-01 13:58:48 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.CommD)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write(t.CommD); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.CommR ([]uint8) (slice)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("CommR")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("CommR")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-01 13:58:48 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.CommR)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write(t.CommR); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Proof ([]uint8) (slice)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Proof")))); err != nil {
|
2019-11-07 18:27:23 +00:00
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
if _, err := w.Write([]byte("Proof")); err != nil {
|
2019-11-07 18:27:23 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-08 18:15:13 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Proof)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write(t.Proof); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Ticket (storage.SealTicket) (struct)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Ticket")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("Ticket")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-01 13:58:48 +00:00
|
|
|
if err := t.Ticket.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.PreCommitMessage (cid.Cid) (struct)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("PreCommitMessage")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("PreCommitMessage")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
|
|
|
|
if t.PreCommitMessage == nil {
|
|
|
|
if _, err := w.Write(cbg.CborNull); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if err := cbg.WriteCid(w, *t.PreCommitMessage); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.PreCommitMessage: %w", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Seed (storage.SealSeed) (struct)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Seed")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("Seed")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-08 18:15:13 +00:00
|
|
|
if err := t.Seed.MarshalCBOR(w); err != nil {
|
2019-11-01 13:58:48 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.CommitMessage (cid.Cid) (struct)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("CommitMessage")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("CommitMessage")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
|
|
|
|
if t.CommitMessage == nil {
|
|
|
|
if _, err := w.Write(cbg.CborNull); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if err := cbg.WriteCid(w, *t.CommitMessage); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.CommitMessage: %w", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-09 20:27:20 +00:00
|
|
|
// t.FaultReportMsg (cid.Cid) (struct)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("FaultReportMsg")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("FaultReportMsg")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-06 14:06:42 +00:00
|
|
|
|
|
|
|
if t.FaultReportMsg == nil {
|
|
|
|
if _, err := w.Write(cbg.CborNull); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if err := cbg.WriteCid(w, *t.FaultReportMsg); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.FaultReportMsg: %w", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.LastErr (string) (string)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("LastErr")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("LastErr")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-04 00:44:29 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.LastErr)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte(t.LastErr)); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
if maj != cbg.MajMap {
|
|
|
|
return fmt.Errorf("cbor input should be of type map")
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
|
|
|
|
2019-12-09 20:27:20 +00:00
|
|
|
if extra != 13 {
|
2019-11-01 13:58:48 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
var name string
|
|
|
|
|
|
|
|
// t.State (uint64) (uint64)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "State" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be State", name)
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
2019-11-05 18:02:28 +00:00
|
|
|
t.State = uint64(extra)
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.SectorID (uint64) (uint64)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "SectorID" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be SectorID", name)
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
2019-11-05 18:02:28 +00:00
|
|
|
t.SectorID = uint64(extra)
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Nonce (uint64) (uint64)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "Nonce" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be Nonce", name)
|
|
|
|
}
|
2019-12-08 16:10:45 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
|
|
|
t.Nonce = uint64(extra)
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Pieces ([]storage.Piece) (slice)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "Pieces" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be Pieces", name)
|
|
|
|
}
|
2019-11-07 18:27:23 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
|
|
|
|
if extra > cbg.MaxLength {
|
2019-11-07 18:27:23 +00:00
|
|
|
return fmt.Errorf("t.Pieces: array too large (%d)", extra)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
|
|
|
if extra > 0 {
|
|
|
|
t.Pieces = make([]Piece, extra)
|
|
|
|
}
|
|
|
|
for i := 0; i < int(extra); i++ {
|
|
|
|
|
|
|
|
var v Piece
|
|
|
|
if err := v.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Pieces[i] = v
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.CommD ([]uint8) (slice)
|
2019-11-07 18:27:23 +00:00
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-11-07 18:27:23 +00:00
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
name = string(sval)
|
2019-11-07 18:27:23 +00:00
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
|
|
|
|
if name != "CommD" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be CommD", name)
|
2019-11-07 18:27:23 +00:00
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
if extra > cbg.ByteArrayMaxLen {
|
|
|
|
return fmt.Errorf("t.CommD: byte array too large (%d)", extra)
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
if maj != cbg.MajByteString {
|
|
|
|
return fmt.Errorf("expected byte array")
|
|
|
|
}
|
|
|
|
t.CommD = make([]byte, extra)
|
|
|
|
if _, err := io.ReadFull(br, t.CommD); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.CommR ([]uint8) (slice)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "CommR" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be CommR", name)
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
if extra > cbg.ByteArrayMaxLen {
|
|
|
|
return fmt.Errorf("t.CommR: byte array too large (%d)", extra)
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
if maj != cbg.MajByteString {
|
|
|
|
return fmt.Errorf("expected byte array")
|
|
|
|
}
|
|
|
|
t.CommR = make([]byte, extra)
|
|
|
|
if _, err := io.ReadFull(br, t.CommR); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Proof ([]uint8) (slice)
|
2019-11-07 18:27:23 +00:00
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-11-07 18:27:23 +00:00
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
name = string(sval)
|
2019-11-07 18:27:23 +00:00
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
|
|
|
|
if name != "Proof" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be Proof", name)
|
2019-11-07 18:27:23 +00:00
|
|
|
}
|
2019-11-08 18:15:13 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
if extra > cbg.ByteArrayMaxLen {
|
|
|
|
return fmt.Errorf("t.Proof: byte array too large (%d)", extra)
|
|
|
|
}
|
2019-11-08 18:15:13 +00:00
|
|
|
if maj != cbg.MajByteString {
|
|
|
|
return fmt.Errorf("expected byte array")
|
|
|
|
}
|
|
|
|
t.Proof = make([]byte, extra)
|
|
|
|
if _, err := io.ReadFull(br, t.Proof); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Ticket (storage.SealTicket) (struct)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "Ticket" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be Ticket", name)
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Ticket.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.PreCommitMessage (cid.Cid) (struct)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "PreCommitMessage" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be PreCommitMessage", name)
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pb, err := br.PeekByte()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if pb == cbg.CborNull[0] {
|
|
|
|
var nbuf [1]byte
|
|
|
|
if _, err := br.Read(nbuf[:]); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.PreCommitMessage: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.PreCommitMessage = &c
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Seed (storage.SealSeed) (struct)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "Seed" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be Seed", name)
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
2019-11-08 18:15:13 +00:00
|
|
|
if err := t.Seed.UnmarshalCBOR(br); err != nil {
|
2019-11-01 13:58:48 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.CommitMessage (cid.Cid) (struct)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "CommitMessage" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be CommitMessage", name)
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pb, err := br.PeekByte()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if pb == cbg.CborNull[0] {
|
|
|
|
var nbuf [1]byte
|
|
|
|
if _, err := br.Read(nbuf[:]); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.CommitMessage: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.CommitMessage = &c
|
|
|
|
}
|
|
|
|
|
2019-12-06 14:06:42 +00:00
|
|
|
}
|
2019-12-09 20:27:20 +00:00
|
|
|
// t.FaultReportMsg (cid.Cid) (struct)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "FaultReportMsg" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be FaultReportMsg", name)
|
|
|
|
}
|
2019-12-06 14:06:42 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pb, err := br.PeekByte()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if pb == cbg.CborNull[0] {
|
|
|
|
var nbuf [1]byte
|
|
|
|
if _, err := br.Read(nbuf[:]); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.FaultReportMsg: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.FaultReportMsg = &c
|
|
|
|
}
|
|
|
|
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.LastErr (string) (string)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "LastErr" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be LastErr", name)
|
|
|
|
}
|
2019-12-04 00:44:29 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.LastErr = string(sval)
|
|
|
|
}
|
2019-11-01 13:58:48 +00:00
|
|
|
return nil
|
|
|
|
}
|