Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backupds: Allow larger values in write log #5776

Merged
merged 2 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/filecoin-project/lotus/chain/types"
sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage"
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
"github.com/filecoin-project/lotus/lib/backupds"
"github.com/filecoin-project/lotus/node/hello"
"github.com/filecoin-project/lotus/paychmgr"
)
Expand Down Expand Up @@ -105,12 +104,4 @@ func main() {
fmt.Println(err)
os.Exit(1)
}

err = gen.WriteTupleEncodersToFile("./lib/backupds/cbor_gen.go", "backupds",
backupds.Entry{},
)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
27 changes: 1 addition & 26 deletions lib/backupds/cbor_gen.go → lib/backupds/cbor.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.

package backupds

import (
"fmt"
"io"
"sort"

cid "github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors"
)

var _ = xerrors.Errorf
var _ = cid.Undef
var _ = sort.Sort

var lengthBufEntry = []byte{131}

func (t *Entry) MarshalCBOR(w io.Writer) error {
Expand All @@ -29,11 +20,6 @@ func (t *Entry) MarshalCBOR(w io.Writer) error {

scratch := make([]byte, 9)

// t.Key ([]uint8) (slice)
if len(t.Key) > cbg.ByteArrayMaxLen {
return xerrors.Errorf("Byte array in field t.Key was too long")
}

if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(t.Key))); err != nil {
return err
}
Expand All @@ -42,11 +28,6 @@ func (t *Entry) MarshalCBOR(w io.Writer) error {
return err
}

// t.Value ([]uint8) (slice)
if len(t.Value) > cbg.ByteArrayMaxLen {
return xerrors.Errorf("Byte array in field t.Value was too long")
}

if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(t.Value))); err != nil {
return err
}
Expand Down Expand Up @@ -93,9 +74,6 @@ func (t *Entry) UnmarshalCBOR(r io.Reader) error {
return err
}

if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Key: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
Expand All @@ -114,9 +92,6 @@ func (t *Entry) UnmarshalCBOR(r io.Reader) error {
return err
}

if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Value: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
Expand Down Expand Up @@ -151,7 +126,7 @@ func (t *Entry) UnmarshalCBOR(r io.Reader) error {
return fmt.Errorf("wrong type for int64 field: %d", maj)
}

t.Timestamp = int64(extraI)
t.Timestamp = extraI
}
return nil
}