cbor gen
This commit is contained in:
parent
68e884ee44
commit
82b95e34b7
@ -146,7 +146,7 @@ func (t *Response) MarshalCBOR(w io.Writer) error {
|
|||||||
|
|
||||||
scratch := make([]byte, 9)
|
scratch := make([]byte, 9)
|
||||||
|
|
||||||
// t.Status (blocksync.status) (uint64)
|
// t.Status (exchange.status) (uint64)
|
||||||
|
|
||||||
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Status)); err != nil {
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Status)); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -164,7 +164,7 @@ func (t *Response) MarshalCBOR(w io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.Chain ([]*blocksync.BSTipSet) (slice)
|
// t.Chain ([]*exchange.BSTipSet) (slice)
|
||||||
if len(t.Chain) > cbg.MaxLength {
|
if len(t.Chain) > cbg.MaxLength {
|
||||||
return xerrors.Errorf("Slice value in field t.Chain was too long")
|
return xerrors.Errorf("Slice value in field t.Chain was too long")
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ func (t *Response) UnmarshalCBOR(r io.Reader) error {
|
|||||||
return fmt.Errorf("cbor input had wrong number of fields")
|
return fmt.Errorf("cbor input had wrong number of fields")
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.Status (blocksync.status) (uint64)
|
// t.Status (exchange.status) (uint64)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ func (t *Response) UnmarshalCBOR(r io.Reader) error {
|
|||||||
|
|
||||||
t.ErrorMessage = string(sval)
|
t.ErrorMessage = string(sval)
|
||||||
}
|
}
|
||||||
// t.Chain ([]*blocksync.BSTipSet) (slice)
|
// t.Chain ([]*exchange.BSTipSet) (slice)
|
||||||
|
|
||||||
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -567,7 +567,7 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.Messages (blocksync.CompactedMessages) (struct)
|
// t.Messages (exchange.CompactedMessages) (struct)
|
||||||
if err := t.Messages.MarshalCBOR(w); err != nil {
|
if err := t.Messages.MarshalCBOR(w); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -621,7 +621,7 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
|
|||||||
t.Blocks[i] = &v
|
t.Blocks[i] = &v
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.Messages (blocksync.CompactedMessages) (struct)
|
// t.Messages (exchange.CompactedMessages) (struct)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1634,3 +1634,131 @@ func (t *BeaconEntry) UnmarshalCBOR(r io.Reader) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lengthBufStateRoot = []byte{131}
|
||||||
|
|
||||||
|
func (t *StateRoot) MarshalCBOR(w io.Writer) error {
|
||||||
|
if t == nil {
|
||||||
|
_, err := w.Write(cbg.CborNull)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := w.Write(lengthBufStateRoot); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
scratch := make([]byte, 9)
|
||||||
|
|
||||||
|
// t.Version (uint64) (uint64)
|
||||||
|
|
||||||
|
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Version)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// t.Actors (cid.Cid) (struct)
|
||||||
|
|
||||||
|
if err := cbg.WriteCidBuf(scratch, w, t.Actors); err != nil {
|
||||||
|
return xerrors.Errorf("failed to write cid field t.Actors: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// t.Info (cid.Cid) (struct)
|
||||||
|
|
||||||
|
if err := cbg.WriteCidBuf(scratch, w, t.Info); err != nil {
|
||||||
|
return xerrors.Errorf("failed to write cid field t.Info: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *StateRoot) UnmarshalCBOR(r io.Reader) error {
|
||||||
|
*t = StateRoot{}
|
||||||
|
|
||||||
|
br := cbg.GetPeeker(r)
|
||||||
|
scratch := make([]byte, 8)
|
||||||
|
|
||||||
|
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
||||||
|
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.Version (uint64) (uint64)
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if maj != cbg.MajUnsignedInt {
|
||||||
|
return fmt.Errorf("wrong type for uint64 field")
|
||||||
|
}
|
||||||
|
t.Version = uint64(extra)
|
||||||
|
|
||||||
|
}
|
||||||
|
// t.Actors (cid.Cid) (struct)
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
c, err := cbg.ReadCid(br)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("failed to read cid field t.Actors: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Actors = c
|
||||||
|
|
||||||
|
}
|
||||||
|
// 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
|
||||||
|
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var lengthBufStateInfo = []byte{128}
|
||||||
|
|
||||||
|
func (t *StateInfo) MarshalCBOR(w io.Writer) error {
|
||||||
|
if t == nil {
|
||||||
|
_, err := w.Write(cbg.CborNull)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := w.Write(lengthBufStateInfo); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *StateInfo) UnmarshalCBOR(r io.Reader) error {
|
||||||
|
*t = StateInfo{}
|
||||||
|
|
||||||
|
br := cbg.GetPeeker(r)
|
||||||
|
scratch := make([]byte, 8)
|
||||||
|
|
||||||
|
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if maj != cbg.MajArray {
|
||||||
|
return fmt.Errorf("cbor input should be of type array")
|
||||||
|
}
|
||||||
|
|
||||||
|
if extra != 0 {
|
||||||
|
return fmt.Errorf("cbor input had wrong number of fields")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
"AddSigner",
|
"AddSigner",
|
||||||
"RemoveSigner",
|
"RemoveSigner",
|
||||||
"SwapSigner",
|
"SwapSigner",
|
||||||
"ChangeNumApprovalsThreshold"
|
"ChangeNumApprovalsThreshold",
|
||||||
|
"LockBalance"
|
||||||
],
|
],
|
||||||
"fil/1/paymentchannel": [
|
"fil/1/paymentchannel": [
|
||||||
"Send",
|
"Send",
|
||||||
|
Loading…
Reference in New Issue
Block a user