2019-09-10 02:05:24 +00:00
|
|
|
package actors
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
2019-11-07 22:55:24 +00:00
|
|
|
"sort"
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-10-18 04:47:41 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/address"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
2019-09-10 02:05:24 +00:00
|
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
|
|
|
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 *InitActorState) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{130}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.AddressMap (cid.Cid) (struct)
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := cbg.WriteCid(w, t.AddressMap); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.AddressMap: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.NextID (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.NextID))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *InitActorState) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
2019-09-10 23:03:17 +00:00
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 2 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.AddressMap (cid.Cid) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
{
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.AddressMap: %w", err)
|
|
|
|
}
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
t.AddressMap = c
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.NextID (uint64) (uint64)
|
2019-09-10 02:05:24 +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 03:42:13 +00:00
|
|
|
t.NextID = uint64(extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *ExecParams) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{130}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Code (cid.Cid) (struct)
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := cbg.WriteCid(w, t.Code); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.Code: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Params ([]uint8) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Params)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write(t.Params); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *ExecParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 2 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Code (cid.Cid) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
{
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.Code: %w", err)
|
|
|
|
}
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
t.Code = c
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Params ([]uint8) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
2019-10-01 15:50:13 +00:00
|
|
|
return fmt.Errorf("t.Params: array too large (%d)", extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajByteString {
|
|
|
|
return fmt.Errorf("expected byte array")
|
|
|
|
}
|
|
|
|
t.Params = make([]byte, extra)
|
|
|
|
if _, err := io.ReadFull(br, t.Params); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *AccountActorState) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Address (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Address.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *AccountActorState) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Address (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Address.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *StorageMinerActorState) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-11-14 16:14:52 +00:00
|
|
|
if _, err := w.Write([]byte{139}); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
// t.t.PreCommittedSectors (map[string]*actors.PreCommittedSector) (map)
|
2019-11-07 22:55:24 +00:00
|
|
|
{
|
|
|
|
if err := cbg.CborWriteHeader(w, cbg.MajMap, uint64(len(t.PreCommittedSectors))); err != nil {
|
2019-11-05 18:02:28 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-07 22:55:24 +00:00
|
|
|
keys := make([]string, 0, len(t.PreCommittedSectors))
|
|
|
|
for k := range t.PreCommittedSectors {
|
|
|
|
keys = append(keys, k)
|
2019-11-05 18:02:28 +00:00
|
|
|
}
|
2019-11-07 22:55:24 +00:00
|
|
|
sort.Strings(keys)
|
|
|
|
for _, k := range keys {
|
|
|
|
v := t.PreCommittedSectors[k]
|
2019-11-05 18:02:28 +00:00
|
|
|
|
2019-11-07 22:55:24 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(k)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte(k)); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := v.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Sectors (cid.Cid) (struct)
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := cbg.WriteCid(w, t.Sectors); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.Sectors: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ProvingSet (cid.Cid) (struct)
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := cbg.WriteCid(w, t.ProvingSet); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.ProvingSet: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-11-05 18:02:28 +00:00
|
|
|
// t.t.Info (cid.Cid) (struct)
|
|
|
|
|
|
|
|
if err := cbg.WriteCid(w, t.Info); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.Info: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.CurrentFaultSet (types.BitField) (struct)
|
2019-09-17 14:20:08 +00:00
|
|
|
if err := t.CurrentFaultSet.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.NextFaultSet (types.BitField) (struct)
|
2019-09-17 14:20:08 +00:00
|
|
|
if err := t.NextFaultSet.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.NextDoneSet (types.BitField) (struct)
|
2019-09-17 14:20:08 +00:00
|
|
|
if err := t.NextDoneSet.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Power (types.BigInt) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Power.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-14 16:14:52 +00:00
|
|
|
// t.t.Active (bool) (bool)
|
|
|
|
if err := cbg.WriteBool(w, t.Active); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-13 23:04:13 +00:00
|
|
|
// t.t.SlashedAt (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SlashedAt))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ProvingPeriodEnd (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ProvingPeriodEnd))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *StorageMinerActorState) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
2019-11-14 16:14:52 +00:00
|
|
|
if extra != 11 {
|
2019-09-10 02:05:24 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
// t.t.PreCommittedSectors (map[string]*actors.PreCommittedSector) (map)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-11-05 18:02:28 +00:00
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajMap {
|
|
|
|
return fmt.Errorf("expected a map (major type 5)")
|
|
|
|
}
|
|
|
|
if extra > 4096 {
|
|
|
|
return fmt.Errorf("t.PreCommittedSectors: map too large")
|
|
|
|
}
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
t.PreCommittedSectors = make(map[string]*PreCommittedSector, extra)
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-11-05 18:02:28 +00:00
|
|
|
for i, l := 0, int(extra); i < l; i++ {
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-11-05 18:02:28 +00:00
|
|
|
var k string
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-11-05 18:02:28 +00:00
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 23:03:17 +00:00
|
|
|
|
2019-11-05 18:02:28 +00:00
|
|
|
k = string(sval)
|
2019-09-10 23:03:17 +00:00
|
|
|
}
|
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
var v *PreCommittedSector
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-11-05 18:02:28 +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 {
|
2019-11-07 12:03:18 +00:00
|
|
|
v = new(PreCommittedSector)
|
2019-11-05 18:02:28 +00:00
|
|
|
if err := v.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2019-09-10 23:03:17 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-11-05 18:02:28 +00:00
|
|
|
t.PreCommittedSectors[k] = v
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Sectors (cid.Cid) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
{
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.Sectors: %w", err)
|
|
|
|
}
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
t.Sectors = c
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ProvingSet (cid.Cid) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
{
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.ProvingSet: %w", err)
|
|
|
|
}
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
t.ProvingSet = c
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-11-05 18:02:28 +00:00
|
|
|
}
|
|
|
|
// t.t.Info (cid.Cid) (struct)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.Info: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Info = c
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.CurrentFaultSet (types.BitField) (struct)
|
2019-09-17 14:20:08 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.CurrentFaultSet.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.NextFaultSet (types.BitField) (struct)
|
2019-09-17 14:20:08 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.NextFaultSet.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.NextDoneSet (types.BitField) (struct)
|
2019-09-17 14:20:08 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.NextDoneSet.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Power (types.BigInt) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Power.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-14 16:14:52 +00:00
|
|
|
// t.t.Active (bool) (bool)
|
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajOther {
|
|
|
|
return fmt.Errorf("booleans must be major type 7")
|
|
|
|
}
|
|
|
|
switch extra {
|
|
|
|
case 20:
|
|
|
|
t.Active = false
|
|
|
|
case 21:
|
|
|
|
t.Active = true
|
|
|
|
default:
|
|
|
|
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
|
|
|
|
}
|
2019-11-13 23:04:13 +00:00
|
|
|
// t.t.SlashedAt (uint64) (uint64)
|
2019-09-10 23:03:17 +00:00
|
|
|
|
2019-11-13 23:04: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.SlashedAt = uint64(extra)
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ProvingPeriodEnd (uint64) (uint64)
|
2019-09-10 02:05:24 +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 03:42:13 +00:00
|
|
|
t.ProvingPeriodEnd = uint64(extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *StorageMinerConstructorParams) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{132}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Owner (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Owner.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Worker (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Worker.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.SectorSize (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorSize))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PeerID (peer.ID) (string)
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.PeerID)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte(t.PeerID)); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *StorageMinerConstructorParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 4 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Owner (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Owner.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Worker (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Worker.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.SectorSize (uint64) (uint64)
|
2019-09-10 23:03:17 +00:00
|
|
|
|
2019-10-16 07:07:16 +00:00
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-10-16 07:07:16 +00:00
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
t.SectorSize = uint64(extra)
|
|
|
|
// t.t.PeerID (peer.ID) (string)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.PeerID = peer.ID(sval)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-11-05 18:02:28 +00:00
|
|
|
func (t *SectorPreCommitInfo) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-11-05 18:02:28 +00:00
|
|
|
if _, err := w.Write([]byte{132}); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
// t.t.SectorNumber (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorNumber))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.CommR ([]uint8) (slice)
|
2019-09-10 02:05:24 +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-11-07 12:03:18 +00:00
|
|
|
// t.t.SealEpoch (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SealEpoch))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
// t.t.DealIDs ([]uint64) (slice)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.DealIDs)))); err != nil {
|
2019-10-22 17:34:59 +00:00
|
|
|
return err
|
|
|
|
}
|
2019-11-07 12:03:18 +00:00
|
|
|
for _, v := range t.DealIDs {
|
|
|
|
if err := cbg.CborWriteHeader(w, cbg.MajUnsignedInt, v); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-11-05 18:02:28 +00:00
|
|
|
func (t *SectorPreCommitInfo) UnmarshalCBOR(r io.Reader) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
2019-11-05 18:02:28 +00:00
|
|
|
if extra != 4 {
|
2019-09-10 02:05:24 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
// t.t.SectorNumber (uint64) (uint64)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-11-07 12:03:18 +00:00
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-07 12:03:18 +00:00
|
|
|
t.SectorNumber = uint64(extra)
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.CommR ([]uint8) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
2019-10-01 15:50:13 +00:00
|
|
|
return fmt.Errorf("t.CommR: array too large (%d)", extra)
|
2019-09-10 02:05:24 +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-11-07 12:03:18 +00:00
|
|
|
// t.t.SealEpoch (uint64) (uint64)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-10-21 11:58:41 +00:00
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-07 12:03:18 +00:00
|
|
|
t.SealEpoch = uint64(extra)
|
|
|
|
// t.t.DealIDs ([]uint64) (slice)
|
2019-11-05 18:02:28 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-11-07 12:03:18 +00:00
|
|
|
if extra > 8192 {
|
|
|
|
return fmt.Errorf("t.DealIDs: array too large (%d)", extra)
|
2019-11-05 18:02:28 +00:00
|
|
|
}
|
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
2019-11-05 18:02:28 +00:00
|
|
|
}
|
2019-11-07 12:03:18 +00:00
|
|
|
if extra > 0 {
|
|
|
|
t.DealIDs = make([]uint64, extra)
|
2019-11-05 18:02:28 +00:00
|
|
|
}
|
2019-11-07 12:03:18 +00:00
|
|
|
for i := 0; i < int(extra); i++ {
|
2019-11-05 18:02:28 +00:00
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
maj, val, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read uint64 for t.DealIDs slice: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return xerrors.Errorf("value read for array t.DealIDs was not a uint, instead got %d", maj)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.DealIDs[i] = val
|
2019-11-05 18:02:28 +00:00
|
|
|
}
|
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *PreCommittedSector) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
2019-11-05 18:02:28 +00:00
|
|
|
return err
|
|
|
|
}
|
2019-11-07 12:03:18 +00:00
|
|
|
if _, err := w.Write([]byte{130}); err != nil {
|
2019-11-05 18:02:28 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
// t.t.Info (actors.SectorPreCommitInfo) (struct)
|
|
|
|
if err := t.Info.MarshalCBOR(w); err != nil {
|
2019-11-05 18:02:28 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
// t.t.ReceivedEpoch (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ReceivedEpoch))); err != nil {
|
2019-11-05 18:02:28 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
func (t *PreCommittedSector) UnmarshalCBOR(r io.Reader) error {
|
2019-11-05 18:02:28 +00:00
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
if extra != 2 {
|
2019-11-05 18:02:28 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
// t.t.Info (actors.SectorPreCommitInfo) (struct)
|
2019-10-22 17:34:59 +00:00
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
{
|
2019-10-22 17:34:59 +00:00
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
if err := t.Info.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-10-22 17:34:59 +00:00
|
|
|
|
2019-11-05 18:02:28 +00:00
|
|
|
}
|
2019-11-07 12:03:18 +00:00
|
|
|
// t.t.ReceivedEpoch (uint64) (uint64)
|
2019-10-22 17:34:59 +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-07 12:03:18 +00:00
|
|
|
t.ReceivedEpoch = uint64(extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MinerInfo) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{132}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Owner (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Owner.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Worker (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Worker.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PeerID (peer.ID) (string)
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.PeerID)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte(t.PeerID)); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.SectorSize (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorSize))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *MinerInfo) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 4 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Owner (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Owner.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Worker (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Worker.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PeerID (peer.ID) (string)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.PeerID = peer.ID(sval)
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.SectorSize (uint64) (uint64)
|
2019-09-10 23:03:17 +00:00
|
|
|
|
2019-10-16 07:07:16 +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-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
t.SectorSize = uint64(extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *SubmitPoStParams) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-19 18:15:14 +00:00
|
|
|
if _, err := w.Write([]byte{130}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Proof ([]uint8) (slice)
|
2019-09-19 18:15:14 +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-11-05 03:42:13 +00:00
|
|
|
// t.t.DoneSet (types.BitField) (struct)
|
2019-09-19 18:15:14 +00:00
|
|
|
if err := t.DoneSet.MarshalCBOR(w); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *SubmitPoStParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
2019-09-19 18:15:14 +00:00
|
|
|
if extra != 2 {
|
2019-09-10 02:05:24 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Proof ([]uint8) (slice)
|
2019-09-19 18:15:14 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
2019-10-01 15:50:13 +00:00
|
|
|
return fmt.Errorf("t.Proof: array too large (%d)", extra)
|
2019-09-19 18:15:14 +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-11-05 03:42:13 +00:00
|
|
|
// t.t.DoneSet (types.BitField) (struct)
|
2019-09-19 18:15:14 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.DoneSet.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-11-13 23:04:13 +00:00
|
|
|
func (t *PaymentVerifyParams) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{130}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.t.Extra ([]uint8) (slice)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Extra)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write(t.Extra); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.t.Proof ([]uint8) (slice)
|
|
|
|
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
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *PaymentVerifyParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 2 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.t.Extra ([]uint8) (slice)
|
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
|
|
|
return fmt.Errorf("t.Extra: array too large (%d)", extra)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajByteString {
|
|
|
|
return fmt.Errorf("expected byte array")
|
|
|
|
}
|
|
|
|
t.Extra = make([]byte, extra)
|
|
|
|
if _, err := io.ReadFull(br, t.Extra); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
// t.t.Proof ([]uint8) (slice)
|
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
|
|
|
return fmt.Errorf("t.Proof: array too large (%d)", extra)
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
func (t *UpdatePeerIDParams) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PeerID (peer.ID) (string)
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.PeerID)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte(t.PeerID)); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *UpdatePeerIDParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PeerID (peer.ID) (string)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.PeerID = peer.ID(sval)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MultiSigActorState) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-10-18 05:04:19 +00:00
|
|
|
if _, err := w.Write([]byte{135}); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Signers ([]address.Address) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Signers)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.Signers {
|
|
|
|
if err := v.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Required (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Required))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.NextTxID (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.NextTxID))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.InitialBalance (types.BigInt) (struct)
|
2019-10-18 05:04:19 +00:00
|
|
|
if err := t.InitialBalance.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.StartingBlock (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.StartingBlock))); err != nil {
|
2019-10-18 05:04:19 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.UnlockDuration (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.UnlockDuration))); err != nil {
|
2019-10-18 05:04:19 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Transactions ([]actors.MTransaction) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Transactions)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.Transactions {
|
|
|
|
if err := v.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *MultiSigActorState) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
2019-10-18 05:04:19 +00:00
|
|
|
if extra != 7 {
|
2019-09-10 02:05:24 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Signers ([]address.Address) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
2019-10-01 15:50:13 +00:00
|
|
|
return fmt.Errorf("t.Signers: array too large (%d)", extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
|
|
|
if extra > 0 {
|
|
|
|
t.Signers = make([]address.Address, extra)
|
|
|
|
}
|
|
|
|
for i := 0; i < int(extra); i++ {
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
var v address.Address
|
|
|
|
if err := v.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Signers[i] = v
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Required (uint64) (uint64)
|
2019-09-10 02:05:24 +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 03:42:13 +00:00
|
|
|
t.Required = uint64(extra)
|
|
|
|
// t.t.NextTxID (uint64) (uint64)
|
2019-09-10 02:05:24 +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 03:42:13 +00:00
|
|
|
t.NextTxID = uint64(extra)
|
|
|
|
// t.t.InitialBalance (types.BigInt) (struct)
|
2019-10-18 05:04:19 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.InitialBalance.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.StartingBlock (uint64) (uint64)
|
2019-10-18 05:04:19 +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 03:42:13 +00:00
|
|
|
t.StartingBlock = uint64(extra)
|
|
|
|
// t.t.UnlockDuration (uint64) (uint64)
|
2019-10-18 05:04:19 +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 03:42:13 +00:00
|
|
|
t.UnlockDuration = uint64(extra)
|
|
|
|
// t.t.Transactions ([]actors.MTransaction) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
2019-10-01 15:50:13 +00:00
|
|
|
return fmt.Errorf("t.Transactions: array too large (%d)", extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
|
|
|
if extra > 0 {
|
|
|
|
t.Transactions = make([]MTransaction, extra)
|
|
|
|
}
|
|
|
|
for i := 0; i < int(extra); i++ {
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
var v MTransaction
|
|
|
|
if err := v.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Transactions[i] = v
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MultiSigConstructorParams) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-10-18 05:04:19 +00:00
|
|
|
if _, err := w.Write([]byte{131}); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Signers ([]address.Address) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Signers)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.Signers {
|
|
|
|
if err := v.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Required (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Required))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
2019-10-18 05:04:19 +00:00
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.UnlockDuration (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.UnlockDuration))); err != nil {
|
2019-10-18 05:04:19 +00:00
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *MultiSigConstructorParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
2019-10-18 05:04:19 +00:00
|
|
|
if extra != 3 {
|
2019-09-10 02:05:24 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Signers ([]address.Address) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
2019-10-01 15:50:13 +00:00
|
|
|
return fmt.Errorf("t.Signers: array too large (%d)", extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
|
|
|
if extra > 0 {
|
|
|
|
t.Signers = make([]address.Address, extra)
|
|
|
|
}
|
|
|
|
for i := 0; i < int(extra); i++ {
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
var v address.Address
|
|
|
|
if err := v.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Signers[i] = v
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Required (uint64) (uint64)
|
2019-09-10 02:05:24 +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 03:42:13 +00:00
|
|
|
t.Required = uint64(extra)
|
|
|
|
// t.t.UnlockDuration (uint64) (uint64)
|
2019-10-18 05:04:19 +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 03:42:13 +00:00
|
|
|
t.UnlockDuration = uint64(extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MultiSigProposeParams) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{132}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.To (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.To.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Value (types.BigInt) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Value.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Method (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Method))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Params ([]uint8) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Params)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write(t.Params); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *MultiSigProposeParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 4 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.To (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.To.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Value (types.BigInt) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Value.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Method (uint64) (uint64)
|
2019-09-10 02:05:24 +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 03:42:13 +00:00
|
|
|
t.Method = uint64(extra)
|
|
|
|
// t.t.Params ([]uint8) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
2019-10-01 15:50:13 +00:00
|
|
|
return fmt.Errorf("t.Params: array too large (%d)", extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajByteString {
|
|
|
|
return fmt.Errorf("expected byte array")
|
|
|
|
}
|
|
|
|
t.Params = make([]byte, extra)
|
|
|
|
if _, err := io.ReadFull(br, t.Params); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MultiSigTxID) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.TxID (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.TxID))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *MultiSigTxID) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.TxID (uint64) (uint64)
|
2019-09-10 02:05:24 +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 03:42:13 +00:00
|
|
|
t.TxID = uint64(extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MultiSigSwapSignerParams) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{130}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.From (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.From.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.To (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.To.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *MultiSigSwapSignerParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 2 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.From (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.From.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.To (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.To.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MultiSigChangeReqParams) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Req (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Req))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *MultiSigChangeReqParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Req (uint64) (uint64)
|
2019-09-10 02:05:24 +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 03:42:13 +00:00
|
|
|
t.Req = uint64(extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MTransaction) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{138}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Created (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Created))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.TxID (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.TxID))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.To (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.To.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Value (types.BigInt) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Value.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Method (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Method))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Params ([]uint8) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Params)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write(t.Params); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Approved ([]address.Address) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Approved)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.Approved {
|
|
|
|
if err := v.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Complete (bool) (bool)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := cbg.WriteBool(w, t.Complete); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Canceled (bool) (bool)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := cbg.WriteBool(w, t.Canceled); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.RetCode (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.RetCode))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *MTransaction) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 10 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Created (uint64) (uint64)
|
2019-09-10 02:05:24 +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 03:42:13 +00:00
|
|
|
t.Created = uint64(extra)
|
|
|
|
// t.t.TxID (uint64) (uint64)
|
2019-09-10 02:05:24 +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 03:42:13 +00:00
|
|
|
t.TxID = uint64(extra)
|
|
|
|
// t.t.To (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.To.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Value (types.BigInt) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Value.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Method (uint64) (uint64)
|
2019-09-10 02:05:24 +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 03:42:13 +00:00
|
|
|
t.Method = uint64(extra)
|
|
|
|
// t.t.Params ([]uint8) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
2019-10-01 15:50:13 +00:00
|
|
|
return fmt.Errorf("t.Params: array too large (%d)", extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajByteString {
|
|
|
|
return fmt.Errorf("expected byte array")
|
|
|
|
}
|
|
|
|
t.Params = make([]byte, extra)
|
|
|
|
if _, err := io.ReadFull(br, t.Params); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Approved ([]address.Address) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
2019-10-01 15:50:13 +00:00
|
|
|
return fmt.Errorf("t.Approved: array too large (%d)", extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
|
|
|
if extra > 0 {
|
|
|
|
t.Approved = make([]address.Address, extra)
|
|
|
|
}
|
|
|
|
for i := 0; i < int(extra); i++ {
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
var v address.Address
|
|
|
|
if err := v.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Approved[i] = v
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Complete (bool) (bool)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajOther {
|
|
|
|
return fmt.Errorf("booleans must be major type 7")
|
|
|
|
}
|
|
|
|
switch extra {
|
|
|
|
case 20:
|
|
|
|
t.Complete = false
|
|
|
|
case 21:
|
|
|
|
t.Complete = true
|
|
|
|
default:
|
|
|
|
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Canceled (bool) (bool)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajOther {
|
|
|
|
return fmt.Errorf("booleans must be major type 7")
|
|
|
|
}
|
|
|
|
switch extra {
|
|
|
|
case 20:
|
|
|
|
t.Canceled = false
|
|
|
|
case 21:
|
|
|
|
t.Canceled = true
|
|
|
|
default:
|
|
|
|
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.RetCode (uint64) (uint64)
|
2019-09-10 02:05:24 +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 03:42:13 +00:00
|
|
|
t.RetCode = uint64(extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MultiSigRemoveSignerParam) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{130}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Signer (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Signer.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Decrease (bool) (bool)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := cbg.WriteBool(w, t.Decrease); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *MultiSigRemoveSignerParam) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 2 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Signer (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Signer.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Decrease (bool) (bool)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajOther {
|
|
|
|
return fmt.Errorf("booleans must be major type 7")
|
|
|
|
}
|
|
|
|
switch extra {
|
|
|
|
case 20:
|
|
|
|
t.Decrease = false
|
|
|
|
case 21:
|
|
|
|
t.Decrease = true
|
|
|
|
default:
|
|
|
|
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MultiSigAddSignerParam) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{130}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Signer (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Signer.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Increase (bool) (bool)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := cbg.WriteBool(w, t.Increase); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *MultiSigAddSignerParam) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 2 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Signer (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Signer.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Increase (bool) (bool)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajOther {
|
|
|
|
return fmt.Errorf("booleans must be major type 7")
|
|
|
|
}
|
|
|
|
switch extra {
|
|
|
|
case 20:
|
|
|
|
t.Increase = false
|
|
|
|
case 21:
|
|
|
|
t.Increase = true
|
|
|
|
default:
|
|
|
|
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *PaymentChannelActorState) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{134}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.From (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.From.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.To (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.To.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ToSend (types.BigInt) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.ToSend.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ClosingAt (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ClosingAt))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.MinCloseHeight (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.MinCloseHeight))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.LaneStates (map[string]*actors.LaneState) (map)
|
2019-11-07 22:55:24 +00:00
|
|
|
{
|
|
|
|
if err := cbg.CborWriteHeader(w, cbg.MajMap, uint64(len(t.LaneStates))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-07 22:55:24 +00:00
|
|
|
keys := make([]string, 0, len(t.LaneStates))
|
|
|
|
for k := range t.LaneStates {
|
|
|
|
keys = append(keys, k)
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-07 22:55:24 +00:00
|
|
|
sort.Strings(keys)
|
|
|
|
for _, k := range keys {
|
|
|
|
v := t.LaneStates[k]
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-11-07 22:55:24 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(k)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte(k)); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := v.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *PaymentChannelActorState) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 6 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.From (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.From.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.To (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.To.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ToSend (types.BigInt) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.ToSend.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ClosingAt (uint64) (uint64)
|
2019-09-10 02:05:24 +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 03:42:13 +00:00
|
|
|
t.ClosingAt = uint64(extra)
|
|
|
|
// t.t.MinCloseHeight (uint64) (uint64)
|
2019-09-10 02:05:24 +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 03:42:13 +00:00
|
|
|
t.MinCloseHeight = uint64(extra)
|
|
|
|
// t.t.LaneStates (map[string]*actors.LaneState) (map)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajMap {
|
|
|
|
return fmt.Errorf("expected a map (major type 5)")
|
|
|
|
}
|
|
|
|
if extra > 4096 {
|
2019-10-01 15:50:13 +00:00
|
|
|
return fmt.Errorf("t.LaneStates: map too large")
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
t.LaneStates = make(map[string]*LaneState, extra)
|
|
|
|
|
|
|
|
for i, l := 0, int(extra); i < l; i++ {
|
|
|
|
|
|
|
|
var k string
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
k = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
var v *LaneState
|
|
|
|
|
2019-09-10 23:03:17 +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 {
|
|
|
|
v = new(LaneState)
|
|
|
|
if err := v.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
t.LaneStates[k] = v
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *PCAConstructorParams) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.To (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.To.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *PCAConstructorParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.To (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.To.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *LaneState) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{131}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Closed (bool) (bool)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := cbg.WriteBool(w, t.Closed); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Redeemed (types.BigInt) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Redeemed.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Nonce (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Nonce))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *LaneState) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 3 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Closed (bool) (bool)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajOther {
|
|
|
|
return fmt.Errorf("booleans must be major type 7")
|
|
|
|
}
|
|
|
|
switch extra {
|
|
|
|
case 20:
|
|
|
|
t.Closed = false
|
|
|
|
case 21:
|
|
|
|
t.Closed = true
|
|
|
|
default:
|
|
|
|
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Redeemed (types.BigInt) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Redeemed.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Nonce (uint64) (uint64)
|
2019-09-10 02:05:24 +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 03:42:13 +00:00
|
|
|
t.Nonce = uint64(extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *PCAUpdateChannelStateParams) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{131}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Sv (types.SignedVoucher) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Sv.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Secret ([]uint8) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Secret)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write(t.Secret); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Proof ([]uint8) (slice)
|
2019-09-10 02:05:24 +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
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *PCAUpdateChannelStateParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 3 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Sv (types.SignedVoucher) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Sv.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Secret ([]uint8) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
2019-10-01 15:50:13 +00:00
|
|
|
return fmt.Errorf("t.Secret: array too large (%d)", extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajByteString {
|
|
|
|
return fmt.Errorf("expected byte array")
|
|
|
|
}
|
|
|
|
t.Secret = make([]byte, extra)
|
|
|
|
if _, err := io.ReadFull(br, t.Secret); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Proof ([]uint8) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
2019-10-01 15:50:13 +00:00
|
|
|
return fmt.Errorf("t.Proof: array too large (%d)", extra)
|
2019-09-10 02:05:24 +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
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{132}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PayChActor (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.PayChActor.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Payer (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Payer.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ChannelMessage (cid.Cid) (struct)
|
2019-09-17 01:56:37 +00:00
|
|
|
|
|
|
|
if t.ChannelMessage == nil {
|
|
|
|
if _, err := w.Write(cbg.CborNull); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if err := cbg.WriteCid(w, *t.ChannelMessage); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.ChannelMessage: %w", err)
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Vouchers ([]*types.SignedVoucher) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Vouchers)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.Vouchers {
|
|
|
|
if err := v.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 4 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PayChActor (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.PayChActor.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Payer (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Payer.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ChannelMessage (cid.Cid) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
{
|
2019-09-17 01:56:37 +00:00
|
|
|
|
|
|
|
pb, err := br.PeekByte()
|
2019-09-10 02:05:24 +00:00
|
|
|
if err != nil {
|
2019-09-17 01:56:37 +00:00
|
|
|
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.ChannelMessage: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.ChannelMessage = &c
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Vouchers ([]*types.SignedVoucher) (slice)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
2019-10-01 15:50:13 +00:00
|
|
|
return fmt.Errorf("t.Vouchers: array too large (%d)", extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
|
|
|
if extra > 0 {
|
2019-09-10 19:58:45 +00:00
|
|
|
t.Vouchers = make([]*types.SignedVoucher, extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
for i := 0; i < int(extra); i++ {
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
var v types.SignedVoucher
|
|
|
|
if err := v.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 19:58:45 +00:00
|
|
|
t.Vouchers[i] = &v
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-10-11 22:59:36 +00:00
|
|
|
func (t *StoragePowerState) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-11-14 23:30:31 +00:00
|
|
|
if _, err := w.Write([]byte{133}); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Miners (cid.Cid) (struct)
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := cbg.WriteCid(w, t.Miners); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.Miners: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-11-13 23:04:13 +00:00
|
|
|
// t.t.ProvingBuckets (cid.Cid) (struct)
|
|
|
|
|
|
|
|
if err := cbg.WriteCid(w, t.ProvingBuckets); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.ProvingBuckets: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.MinerCount (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.MinerCount))); err != nil {
|
2019-09-12 04:12:35 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-14 23:30:31 +00:00
|
|
|
// t.t.LastMinerCheck (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.LastMinerCheck))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.TotalStorage (types.BigInt) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.TotalStorage.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-10-11 22:59:36 +00:00
|
|
|
func (t *StoragePowerState) UnmarshalCBOR(r io.Reader) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
2019-11-14 23:30:31 +00:00
|
|
|
if extra != 5 {
|
2019-09-10 02:05:24 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Miners (cid.Cid) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
{
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.Miners: %w", err)
|
|
|
|
}
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
t.Miners = c
|
2019-09-17 01:56:37 +00:00
|
|
|
|
2019-11-13 23:04:13 +00:00
|
|
|
}
|
|
|
|
// t.t.ProvingBuckets (cid.Cid) (struct)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.ProvingBuckets: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.ProvingBuckets = c
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.MinerCount (uint64) (uint64)
|
2019-09-12 04:12:35 +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 03:42:13 +00:00
|
|
|
t.MinerCount = uint64(extra)
|
2019-11-14 23:30:31 +00:00
|
|
|
// t.t.LastMinerCheck (uint64) (uint64)
|
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
|
|
|
t.LastMinerCheck = uint64(extra)
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.TotalStorage (types.BigInt) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.TotalStorage.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *CreateStorageMinerParams) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{132}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Owner (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Owner.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Worker (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Worker.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.SectorSize (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorSize))); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PeerID (peer.ID) (string)
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.PeerID)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte(t.PeerID)); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *CreateStorageMinerParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 4 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Owner (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Owner.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Worker (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Worker.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.SectorSize (uint64) (uint64)
|
2019-09-10 23:03:17 +00:00
|
|
|
|
2019-10-16 07:07:16 +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-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
t.SectorSize = uint64(extra)
|
|
|
|
// t.t.PeerID (peer.ID) (string)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.PeerID = peer.ID(sval)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-11-14 16:14:52 +00:00
|
|
|
func (t *IsValidMinerParam) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Addr (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Addr.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-11-14 16:14:52 +00:00
|
|
|
func (t *IsValidMinerParam) UnmarshalCBOR(r io.Reader) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Addr (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Addr.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *PowerLookupParams) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Miner (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Miner.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *PowerLookupParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Miner (address.Address) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Miner.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *UpdateStorageParams) MarshalCBOR(w io.Writer) error {
|
2019-09-10 23:03:17 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-11-13 23:04:13 +00:00
|
|
|
if _, err := w.Write([]byte{131}); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Delta (types.BigInt) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
if err := t.Delta.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-11-13 23:04:13 +00:00
|
|
|
|
|
|
|
// t.t.NextProvingPeriodEnd (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.NextProvingPeriodEnd))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.t.PreviousProvingPeriodEnd (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.PreviousProvingPeriodEnd))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
func (t *UpdateStorageParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
2019-11-13 23:04:13 +00:00
|
|
|
if extra != 3 {
|
2019-09-10 02:05:24 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Delta (types.BigInt) (struct)
|
2019-09-10 02:05:24 +00:00
|
|
|
|
2019-09-10 23:03:17 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Delta.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
}
|
2019-11-13 23:04:13 +00:00
|
|
|
// t.t.NextProvingPeriodEnd (uint64) (uint64)
|
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
|
|
|
t.NextProvingPeriodEnd = uint64(extra)
|
|
|
|
// t.t.PreviousProvingPeriodEnd (uint64) (uint64)
|
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
|
|
|
t.PreviousProvingPeriodEnd = uint64(extra)
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
2019-09-12 04:12:35 +00:00
|
|
|
|
2019-09-13 01:06:06 +00:00
|
|
|
func (t *ArbitrateConsensusFaultParams) MarshalCBOR(w io.Writer) error {
|
2019-09-12 04:12:35 +00:00
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{130}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Block1 (types.BlockHeader) (struct)
|
2019-09-12 04:12:35 +00:00
|
|
|
if err := t.Block1.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Block2 (types.BlockHeader) (struct)
|
2019-09-12 04:12:35 +00:00
|
|
|
if err := t.Block2.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-13 01:06:06 +00:00
|
|
|
func (t *ArbitrateConsensusFaultParams) UnmarshalCBOR(r io.Reader) error {
|
2019-09-12 04:12:35 +00:00
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 2 {
|
2019-09-12 23:48:03 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
2019-09-12 04:12:35 +00:00
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Block1 (types.BlockHeader) (struct)
|
2019-09-12 04:12:35 +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 {
|
|
|
|
t.Block1 = new(types.BlockHeader)
|
|
|
|
if err := t.Block1.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Block2 (types.BlockHeader) (struct)
|
2019-09-12 04:12:35 +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 {
|
|
|
|
t.Block2 = new(types.BlockHeader)
|
|
|
|
if err := t.Block2.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *PledgeCollateralParams) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Size (types.BigInt) (struct)
|
2019-09-12 04:12:35 +00:00
|
|
|
if err := t.Size.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *PledgeCollateralParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Size (types.BigInt) (struct)
|
2019-09-12 04:12:35 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Size.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2019-09-12 23:48:03 +00:00
|
|
|
|
|
|
|
func (t *MinerSlashConsensusFault) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{131}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Slasher (address.Address) (struct)
|
2019-09-12 23:48:03 +00:00
|
|
|
if err := t.Slasher.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.AtHeight (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.AtHeight))); err != nil {
|
2019-09-12 23:48:03 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.SlashedCollateral (types.BigInt) (struct)
|
2019-09-12 23:48:03 +00:00
|
|
|
if err := t.SlashedCollateral.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MinerSlashConsensusFault) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 3 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Slasher (address.Address) (struct)
|
2019-09-12 23:48:03 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Slasher.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.AtHeight (uint64) (uint64)
|
2019-09-12 23:48:03 +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 03:42:13 +00:00
|
|
|
t.AtHeight = uint64(extra)
|
|
|
|
// t.t.SlashedCollateral (types.BigInt) (struct)
|
2019-09-12 23:48:03 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.SlashedCollateral.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2019-10-18 06:16:59 +00:00
|
|
|
|
|
|
|
func (t *StorageParticipantBalance) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{130}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Locked (types.BigInt) (struct)
|
2019-10-18 06:16:59 +00:00
|
|
|
if err := t.Locked.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Available (types.BigInt) (struct)
|
2019-10-18 06:16:59 +00:00
|
|
|
if err := t.Available.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *StorageParticipantBalance) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 2 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Locked (types.BigInt) (struct)
|
2019-10-18 06:16:59 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Locked.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Available (types.BigInt) (struct)
|
2019-10-18 06:16:59 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Available.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *StorageMarketState) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-10-19 04:54:22 +00:00
|
|
|
if _, err := w.Write([]byte{131}); err != nil {
|
2019-10-18 06:16:59 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Balances (cid.Cid) (struct)
|
2019-10-18 06:16:59 +00:00
|
|
|
|
|
|
|
if err := cbg.WriteCid(w, t.Balances); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.Balances: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Deals (cid.Cid) (struct)
|
2019-10-18 06:16:59 +00:00
|
|
|
|
|
|
|
if err := cbg.WriteCid(w, t.Deals); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.Deals: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.NextDealID (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.NextDealID))); err != nil {
|
2019-10-19 04:54:22 +00:00
|
|
|
return err
|
|
|
|
}
|
2019-10-18 06:16:59 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *StorageMarketState) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
2019-10-19 04:54:22 +00:00
|
|
|
if extra != 3 {
|
2019-10-18 06:16:59 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Balances (cid.Cid) (struct)
|
2019-10-18 06:16:59 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.Balances: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Balances = c
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Deals (cid.Cid) (struct)
|
2019-10-18 06:16:59 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.Deals: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Deals = c
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.NextDealID (uint64) (uint64)
|
2019-10-19 04:54:22 +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 03:42:13 +00:00
|
|
|
t.NextDealID = uint64(extra)
|
2019-10-18 06:16:59 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *WithdrawBalanceParams) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Balance (types.BigInt) (struct)
|
2019-10-18 06:16:59 +00:00
|
|
|
if err := t.Balance.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *WithdrawBalanceParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Balance (types.BigInt) (struct)
|
2019-10-18 06:16:59 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Balance.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2019-10-19 04:54:22 +00:00
|
|
|
|
|
|
|
func (t *StorageDealProposal) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-10-22 10:20:43 +00:00
|
|
|
if _, err := w.Write([]byte{138}); err != nil {
|
2019-10-19 04:54:22 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PieceRef ([]uint8) (slice)
|
2019-10-21 08:53:41 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.PieceRef)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write(t.PieceRef); err != nil {
|
|
|
|
return err
|
2019-10-19 04:54:22 +00:00
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PieceSize (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.PieceSize))); err != nil {
|
2019-10-19 04:54:22 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PieceSerialization (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.PieceSerialization))); err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Client (address.Address) (struct)
|
2019-10-19 04:54:22 +00:00
|
|
|
if err := t.Client.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Provider (address.Address) (struct)
|
2019-10-19 04:54:22 +00:00
|
|
|
if err := t.Provider.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ProposalExpiration (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ProposalExpiration))); err != nil {
|
2019-10-19 04:54:22 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Duration (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Duration))); err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
2019-10-19 04:54:22 +00:00
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.StoragePricePerEpoch (types.BigInt) (struct)
|
2019-10-29 10:01:18 +00:00
|
|
|
if err := t.StoragePricePerEpoch.MarshalCBOR(w); err != nil {
|
2019-10-19 04:54:22 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.StorageCollateral (types.BigInt) (struct)
|
2019-10-19 04:54:22 +00:00
|
|
|
if err := t.StorageCollateral.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ProposerSignature (types.Signature) (struct)
|
2019-10-19 04:54:22 +00:00
|
|
|
if err := t.ProposerSignature.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *StorageDealProposal) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
2019-10-22 10:20:43 +00:00
|
|
|
if extra != 10 {
|
2019-10-19 04:54:22 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PieceRef ([]uint8) (slice)
|
2019-10-19 04:54:22 +00:00
|
|
|
|
2019-10-21 08:53:41 +00:00
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
|
|
|
return fmt.Errorf("t.PieceRef: array too large (%d)", extra)
|
|
|
|
}
|
2019-10-19 04:54:22 +00:00
|
|
|
|
2019-10-21 08:53:41 +00:00
|
|
|
if maj != cbg.MajByteString {
|
|
|
|
return fmt.Errorf("expected byte array")
|
|
|
|
}
|
|
|
|
t.PieceRef = make([]byte, extra)
|
|
|
|
if _, err := io.ReadFull(br, t.PieceRef); err != nil {
|
|
|
|
return err
|
2019-10-19 04:54:22 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PieceSize (uint64) (uint64)
|
2019-10-19 04:54:22 +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 03:42:13 +00:00
|
|
|
t.PieceSize = uint64(extra)
|
|
|
|
// t.t.PieceSerialization (uint64) (uint64)
|
2019-10-22 10:20:43 +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 03:42:13 +00:00
|
|
|
t.PieceSerialization = uint64(extra)
|
|
|
|
// t.t.Client (address.Address) (struct)
|
2019-10-19 04:54:22 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Client.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Provider (address.Address) (struct)
|
2019-10-19 04:54:22 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Provider.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ProposalExpiration (uint64) (uint64)
|
2019-10-19 04:54:22 +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 03:42:13 +00:00
|
|
|
t.ProposalExpiration = uint64(extra)
|
|
|
|
// t.t.Duration (uint64) (uint64)
|
2019-10-19 04:54:22 +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 03:42:13 +00:00
|
|
|
t.Duration = uint64(extra)
|
|
|
|
// t.t.StoragePricePerEpoch (types.BigInt) (struct)
|
2019-10-19 04:54:22 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
2019-10-29 10:01:18 +00:00
|
|
|
if err := t.StoragePricePerEpoch.UnmarshalCBOR(br); err != nil {
|
2019-10-19 04:54:22 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.StorageCollateral (types.BigInt) (struct)
|
2019-10-19 04:54:22 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.StorageCollateral.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ProposerSignature (types.Signature) (struct)
|
2019-10-19 04:54:22 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
2019-10-22 10:20:43 +00:00
|
|
|
pb, err := br.PeekByte()
|
|
|
|
if err != nil {
|
2019-10-19 04:54:22 +00:00
|
|
|
return err
|
|
|
|
}
|
2019-10-22 10:20:43 +00:00
|
|
|
if pb == cbg.CborNull[0] {
|
|
|
|
var nbuf [1]byte
|
|
|
|
if _, err := br.Read(nbuf[:]); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
t.ProposerSignature = new(types.Signature)
|
|
|
|
if err := t.ProposerSignature.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2019-10-19 04:54:22 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *StorageDeal) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{130}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Proposal (actors.StorageDealProposal) (struct)
|
2019-10-19 04:54:22 +00:00
|
|
|
if err := t.Proposal.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.CounterSignature (types.Signature) (struct)
|
2019-10-19 04:54:22 +00:00
|
|
|
if err := t.CounterSignature.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *StorageDeal) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 2 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Proposal (actors.StorageDealProposal) (struct)
|
2019-10-19 04:54:22 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Proposal.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.CounterSignature (types.Signature) (struct)
|
2019-10-19 04:54:22 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
2019-10-23 17:39:14 +00:00
|
|
|
pb, err := br.PeekByte()
|
|
|
|
if err != nil {
|
2019-10-19 04:54:22 +00:00
|
|
|
return err
|
|
|
|
}
|
2019-10-23 17:39:14 +00:00
|
|
|
if pb == cbg.CborNull[0] {
|
|
|
|
var nbuf [1]byte
|
|
|
|
if _, err := br.Read(nbuf[:]); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
t.CounterSignature = new(types.Signature)
|
|
|
|
if err := t.CounterSignature.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2019-10-19 04:54:22 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *PublishStorageDealsParams) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Deals ([]actors.StorageDeal) (slice)
|
2019-10-19 04:54:22 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Deals)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.Deals {
|
|
|
|
if err := v.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *PublishStorageDealsParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Deals ([]actors.StorageDeal) (slice)
|
2019-10-19 04:54:22 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
|
|
|
return fmt.Errorf("t.Deals: array too large (%d)", extra)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
|
|
|
if extra > 0 {
|
|
|
|
t.Deals = make([]StorageDeal, extra)
|
|
|
|
}
|
|
|
|
for i := 0; i < int(extra); i++ {
|
|
|
|
|
|
|
|
var v StorageDeal
|
|
|
|
if err := v.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Deals[i] = v
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *PublishStorageDealResponse) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.DealIDs ([]uint64) (slice)
|
2019-10-19 04:54:22 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.DealIDs)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.DealIDs {
|
|
|
|
if err := cbg.CborWriteHeader(w, cbg.MajUnsignedInt, v); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *PublishStorageDealResponse) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.DealIDs ([]uint64) (slice)
|
2019-10-19 04:54:22 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
|
|
|
return fmt.Errorf("t.DealIDs: array too large (%d)", extra)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
|
|
|
if extra > 0 {
|
|
|
|
t.DealIDs = make([]uint64, extra)
|
|
|
|
}
|
|
|
|
for i := 0; i < int(extra); i++ {
|
|
|
|
|
|
|
|
maj, val, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read uint64 for t.DealIDs slice: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return xerrors.Errorf("value read for array t.DealIDs was not a uint, instead got %d", maj)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.DealIDs[i] = val
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2019-10-19 10:20:33 +00:00
|
|
|
|
|
|
|
func (t *ActivateStorageDealsParams) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Deals ([]uint64) (slice)
|
2019-10-19 10:20:33 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Deals)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.Deals {
|
|
|
|
if err := cbg.CborWriteHeader(w, cbg.MajUnsignedInt, v); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *ActivateStorageDealsParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Deals ([]uint64) (slice)
|
2019-10-19 10:20:33 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
|
|
|
return fmt.Errorf("t.Deals: array too large (%d)", extra)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
|
|
|
if extra > 0 {
|
|
|
|
t.Deals = make([]uint64, extra)
|
|
|
|
}
|
|
|
|
for i := 0; i < int(extra); i++ {
|
|
|
|
|
|
|
|
maj, val, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read uint64 for t.Deals slice: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return xerrors.Errorf("value read for array t.Deals was not a uint, instead got %d", maj)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Deals[i] = val
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *ProcessStorageDealsPaymentParams) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.DealIDs ([]uint64) (slice)
|
2019-10-19 10:20:33 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.DealIDs)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.DealIDs {
|
|
|
|
if err := cbg.CborWriteHeader(w, cbg.MajUnsignedInt, v); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *ProcessStorageDealsPaymentParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.DealIDs ([]uint64) (slice)
|
2019-10-19 10:20:33 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
|
|
|
return fmt.Errorf("t.DealIDs: array too large (%d)", extra)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
|
|
|
if extra > 0 {
|
|
|
|
t.DealIDs = make([]uint64, extra)
|
|
|
|
}
|
|
|
|
for i := 0; i < int(extra); i++ {
|
|
|
|
|
|
|
|
maj, val, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read uint64 for t.DealIDs slice: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return xerrors.Errorf("value read for array t.DealIDs was not a uint, instead got %d", maj)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.DealIDs[i] = val
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2019-10-22 19:29:05 +00:00
|
|
|
|
|
|
|
func (t *OnChainDeal) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{130}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Deal (actors.StorageDeal) (struct)
|
2019-10-22 19:29:05 +00:00
|
|
|
if err := t.Deal.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ActivationEpoch (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ActivationEpoch))); err != nil {
|
2019-10-22 19:29:05 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *OnChainDeal) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 2 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Deal (actors.StorageDeal) (struct)
|
2019-10-22 19:29:05 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Deal.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ActivationEpoch (uint64) (uint64)
|
2019-10-22 19:29:05 +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 03:42:13 +00:00
|
|
|
t.ActivationEpoch = uint64(extra)
|
2019-10-22 19:29:05 +00:00
|
|
|
return nil
|
|
|
|
}
|
2019-11-05 18:02:28 +00:00
|
|
|
|
|
|
|
func (t *ComputeDataCommitmentParams) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{130}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.t.DealIDs ([]uint64) (slice)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.DealIDs)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.DealIDs {
|
|
|
|
if err := cbg.CborWriteHeader(w, cbg.MajUnsignedInt, v); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.t.SectorSize (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorSize))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *ComputeDataCommitmentParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 2 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.t.DealIDs ([]uint64) (slice)
|
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
|
|
|
return fmt.Errorf("t.DealIDs: array too large (%d)", extra)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
|
|
|
if extra > 0 {
|
|
|
|
t.DealIDs = make([]uint64, extra)
|
|
|
|
}
|
|
|
|
for i := 0; i < int(extra); i++ {
|
|
|
|
|
|
|
|
maj, val, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read uint64 for t.DealIDs slice: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return xerrors.Errorf("value read for array t.DealIDs was not a uint, instead got %d", maj)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.DealIDs[i] = val
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.t.SectorSize (uint64) (uint64)
|
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
|
|
|
t.SectorSize = uint64(extra)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *SectorProveCommitInfo) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{131}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.t.Proof ([]uint8) (slice)
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.t.SectorID (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorID))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.t.DealIDs ([]uint64) (slice)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.DealIDs)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.DealIDs {
|
|
|
|
if err := cbg.CborWriteHeader(w, cbg.MajUnsignedInt, v); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *SectorProveCommitInfo) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 3 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.t.Proof ([]uint8) (slice)
|
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
|
|
|
return fmt.Errorf("t.Proof: array too large (%d)", extra)
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
// t.t.SectorID (uint64) (uint64)
|
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
|
|
|
t.SectorID = uint64(extra)
|
|
|
|
// t.t.DealIDs ([]uint64) (slice)
|
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if extra > 8192 {
|
|
|
|
return fmt.Errorf("t.DealIDs: array too large (%d)", extra)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
|
|
|
if extra > 0 {
|
|
|
|
t.DealIDs = make([]uint64, extra)
|
|
|
|
}
|
|
|
|
for i := 0; i < int(extra); i++ {
|
|
|
|
|
|
|
|
maj, val, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read uint64 for t.DealIDs slice: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return xerrors.Errorf("value read for array t.DealIDs was not a uint, instead got %d", maj)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.DealIDs[i] = val
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2019-11-14 11:56:17 +00:00
|
|
|
|
|
|
|
func (t *CheckMinerParams) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.t.NetworkPower (types.BigInt) (struct)
|
|
|
|
if err := t.NetworkPower.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *CheckMinerParams) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.t.NetworkPower (types.BigInt) (struct)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.NetworkPower.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|