2020-02-12 18:08:49 +00:00
|
|
|
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
|
|
|
|
|
|
|
|
package hello
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
|
2020-02-25 20:21:58 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
2020-08-06 21:27:23 +00:00
|
|
|
cid "github.com/ipfs/go-cid"
|
2020-02-12 18:08:49 +00:00
|
|
|
cbg "github.com/whyrusleeping/cbor-gen"
|
|
|
|
xerrors "golang.org/x/xerrors"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ = xerrors.Errorf
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
var lengthBufHelloMessage = []byte{132}
|
|
|
|
|
2020-02-12 18:08:49 +00:00
|
|
|
func (t *HelloMessage) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2020-05-04 22:19:48 +00:00
|
|
|
if _, err := w.Write(lengthBufHelloMessage); err != nil {
|
2020-02-12 18:08:49 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
scratch := make([]byte, 9)
|
|
|
|
|
2020-02-12 18:08:49 +00:00
|
|
|
// t.HeaviestTipSet ([]cid.Cid) (slice)
|
|
|
|
if len(t.HeaviestTipSet) > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Slice value in field t.HeaviestTipSet was too long")
|
|
|
|
}
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.HeaviestTipSet))); err != nil {
|
2020-02-12 18:08:49 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.HeaviestTipSet {
|
2020-05-04 22:19:48 +00:00
|
|
|
if err := cbg.WriteCidBuf(scratch, w, v); err != nil {
|
2020-02-12 18:08:49 +00:00
|
|
|
return xerrors.Errorf("failed writing cid field t.HeaviestTipSet: %w", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-25 20:21:58 +00:00
|
|
|
// t.HeaviestTipSetHeight (abi.ChainEpoch) (int64)
|
|
|
|
if t.HeaviestTipSetHeight >= 0 {
|
2020-05-04 22:19:48 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.HeaviestTipSetHeight)); err != nil {
|
2020-02-25 20:21:58 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
2020-05-04 22:19:48 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.HeaviestTipSetHeight-1)); err != nil {
|
2020-02-25 20:21:58 +00:00
|
|
|
return err
|
|
|
|
}
|
2020-02-12 18:08:49 +00:00
|
|
|
}
|
|
|
|
|
2020-02-25 20:21:58 +00:00
|
|
|
// t.HeaviestTipSetWeight (big.Int) (struct)
|
2020-02-12 18:08:49 +00:00
|
|
|
if err := t.HeaviestTipSetWeight.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.GenesisHash (cid.Cid) (struct)
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
if err := cbg.WriteCidBuf(scratch, w, t.GenesisHash); err != nil {
|
2020-02-12 18:08:49 +00:00
|
|
|
return xerrors.Errorf("failed to write cid field t.GenesisHash: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *HelloMessage) UnmarshalCBOR(r io.Reader) error {
|
2020-07-14 11:45:45 +00:00
|
|
|
*t = HelloMessage{}
|
|
|
|
|
2020-02-12 18:08:49 +00:00
|
|
|
br := cbg.GetPeeker(r)
|
2020-05-04 22:19:48 +00:00
|
|
|
scratch := make([]byte, 8)
|
2020-02-12 18:08:49 +00:00
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
2020-02-12 18:08:49 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-02-12 18:23:15 +00:00
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
2020-02-12 18:08:49 +00:00
|
|
|
}
|
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
if extra != 4 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
2020-02-12 18:08:49 +00:00
|
|
|
}
|
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
// t.HeaviestTipSet ([]cid.Cid) (slice)
|
2020-02-12 18:08:49 +00:00
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
2020-02-12 18:23:15 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-02-12 18:08:49 +00:00
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
if extra > cbg.MaxLength {
|
|
|
|
return fmt.Errorf("t.HeaviestTipSet: array too large (%d)", extra)
|
|
|
|
}
|
2020-02-12 18:08:49 +00:00
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
2020-04-17 17:53:09 +00:00
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
if extra > 0 {
|
|
|
|
t.HeaviestTipSet = make([]cid.Cid, extra)
|
|
|
|
}
|
2020-04-17 17:53:09 +00:00
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
for i := 0; i < int(extra); i++ {
|
2020-02-12 18:08:49 +00:00
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("reading cid field t.HeaviestTipSet failed: %w", err)
|
|
|
|
}
|
|
|
|
t.HeaviestTipSet[i] = c
|
|
|
|
}
|
2020-02-12 18:08:49 +00:00
|
|
|
|
2020-02-25 20:21:58 +00:00
|
|
|
// t.HeaviestTipSetHeight (abi.ChainEpoch) (int64)
|
|
|
|
{
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
2020-02-25 20:21:58 +00:00
|
|
|
var extraI int64
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
switch maj {
|
|
|
|
case cbg.MajUnsignedInt:
|
|
|
|
extraI = int64(extra)
|
|
|
|
if extraI < 0 {
|
|
|
|
return fmt.Errorf("int64 positive overflow")
|
|
|
|
}
|
|
|
|
case cbg.MajNegativeInt:
|
|
|
|
extraI = int64(extra)
|
|
|
|
if extraI < 0 {
|
|
|
|
return fmt.Errorf("int64 negative oveflow")
|
|
|
|
}
|
|
|
|
extraI = -1 - extraI
|
|
|
|
default:
|
|
|
|
return fmt.Errorf("wrong type for int64 field: %d", maj)
|
|
|
|
}
|
2020-02-12 18:08:49 +00:00
|
|
|
|
2020-02-25 20:21:58 +00:00
|
|
|
t.HeaviestTipSetHeight = abi.ChainEpoch(extraI)
|
2020-02-12 18:23:15 +00:00
|
|
|
}
|
2020-02-25 20:21:58 +00:00
|
|
|
// t.HeaviestTipSetWeight (big.Int) (struct)
|
2020-02-12 18:08:49 +00:00
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
{
|
2020-02-12 18:08:49 +00:00
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
if err := t.HeaviestTipSetWeight.UnmarshalCBOR(br); err != nil {
|
2020-03-21 21:17:01 +00:00
|
|
|
return xerrors.Errorf("unmarshaling t.HeaviestTipSetWeight: %w", err)
|
2020-02-12 18:23:15 +00:00
|
|
|
}
|
2020-02-12 18:08:49 +00:00
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
}
|
|
|
|
// t.GenesisHash (cid.Cid) (struct)
|
2020-02-12 18:08:49 +00:00
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
{
|
2020-02-12 18:08:49 +00:00
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.GenesisHash: %w", err)
|
|
|
|
}
|
2020-02-12 18:08:49 +00:00
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
t.GenesisHash = c
|
2020-02-12 18:08:49 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2020-02-12 18:23:15 +00:00
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
var lengthBufLatencyMessage = []byte{130}
|
|
|
|
|
2020-02-12 18:08:49 +00:00
|
|
|
func (t *LatencyMessage) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2020-05-04 22:19:48 +00:00
|
|
|
if _, err := w.Write(lengthBufLatencyMessage); err != nil {
|
2020-02-12 18:08:49 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
scratch := make([]byte, 9)
|
|
|
|
|
2020-08-04 15:33:29 +00:00
|
|
|
// t.TArrival (int64) (int64)
|
|
|
|
if t.TArrival >= 0 {
|
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.TArrival)); err != nil {
|
2020-02-12 18:23:15 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
2020-08-04 15:33:29 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.TArrival-1)); err != nil {
|
2020-02-12 18:23:15 +00:00
|
|
|
return err
|
|
|
|
}
|
2020-02-12 18:08:49 +00:00
|
|
|
}
|
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
// t.TSent (int64) (int64)
|
|
|
|
if t.TSent >= 0 {
|
2020-05-04 22:19:48 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.TSent)); err != nil {
|
2020-02-12 18:23:15 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
2020-05-04 22:19:48 +00:00
|
|
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.TSent-1)); err != nil {
|
2020-02-12 18:23:15 +00:00
|
|
|
return err
|
|
|
|
}
|
2020-02-12 18:08:49 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *LatencyMessage) UnmarshalCBOR(r io.Reader) error {
|
2020-07-14 11:45:45 +00:00
|
|
|
*t = LatencyMessage{}
|
|
|
|
|
2020-02-12 18:08:49 +00:00
|
|
|
br := cbg.GetPeeker(r)
|
2020-05-04 22:19:48 +00:00
|
|
|
scratch := make([]byte, 8)
|
2020-02-12 18:08:49 +00:00
|
|
|
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
2020-02-12 18:08:49 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-02-12 18:23:15 +00:00
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("cbor input should be of type array")
|
2020-02-12 18:08:49 +00:00
|
|
|
}
|
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
if extra != 2 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
2020-02-12 18:08:49 +00:00
|
|
|
}
|
|
|
|
|
2020-08-04 15:33:29 +00:00
|
|
|
// t.TArrival (int64) (int64)
|
2020-02-12 18:23:15 +00:00
|
|
|
{
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
2020-02-12 18:23:15 +00:00
|
|
|
var extraI int64
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-02-12 18:08:49 +00:00
|
|
|
}
|
2020-02-12 18:23:15 +00:00
|
|
|
switch maj {
|
|
|
|
case cbg.MajUnsignedInt:
|
|
|
|
extraI = int64(extra)
|
|
|
|
if extraI < 0 {
|
|
|
|
return fmt.Errorf("int64 positive overflow")
|
2020-02-12 18:08:49 +00:00
|
|
|
}
|
2020-02-12 18:23:15 +00:00
|
|
|
case cbg.MajNegativeInt:
|
|
|
|
extraI = int64(extra)
|
|
|
|
if extraI < 0 {
|
|
|
|
return fmt.Errorf("int64 negative oveflow")
|
2020-02-12 18:08:49 +00:00
|
|
|
}
|
2020-02-12 18:23:15 +00:00
|
|
|
extraI = -1 - extraI
|
|
|
|
default:
|
|
|
|
return fmt.Errorf("wrong type for int64 field: %d", maj)
|
|
|
|
}
|
2020-02-12 18:08:49 +00:00
|
|
|
|
2020-08-04 15:33:29 +00:00
|
|
|
t.TArrival = int64(extraI)
|
2020-02-12 18:23:15 +00:00
|
|
|
}
|
|
|
|
// t.TSent (int64) (int64)
|
|
|
|
{
|
2020-05-04 22:19:48 +00:00
|
|
|
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
2020-02-12 18:23:15 +00:00
|
|
|
var extraI int64
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
switch maj {
|
|
|
|
case cbg.MajUnsignedInt:
|
|
|
|
extraI = int64(extra)
|
|
|
|
if extraI < 0 {
|
|
|
|
return fmt.Errorf("int64 positive overflow")
|
2020-02-12 18:08:49 +00:00
|
|
|
}
|
2020-02-12 18:23:15 +00:00
|
|
|
case cbg.MajNegativeInt:
|
|
|
|
extraI = int64(extra)
|
|
|
|
if extraI < 0 {
|
|
|
|
return fmt.Errorf("int64 negative oveflow")
|
2020-02-12 18:08:49 +00:00
|
|
|
}
|
2020-02-12 18:23:15 +00:00
|
|
|
extraI = -1 - extraI
|
2020-02-12 18:08:49 +00:00
|
|
|
default:
|
2020-02-12 18:23:15 +00:00
|
|
|
return fmt.Errorf("wrong type for int64 field: %d", maj)
|
2020-02-12 18:08:49 +00:00
|
|
|
}
|
|
|
|
|
2020-02-12 18:23:15 +00:00
|
|
|
t.TSent = int64(extraI)
|
|
|
|
}
|
2020-02-12 18:08:49 +00:00
|
|
|
return nil
|
|
|
|
}
|