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

type: venus-shared: add pad byte index #4777

Merged
merged 3 commits into from
Feb 17, 2022
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
3 changes: 1 addition & 2 deletions venus-devtool/api-gen/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/exitcode"
commontypes "github.com/ipfs-force-community/venus-common-utils/types"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-graphsync"
textselector "github.com/ipld/go-ipld-selector-text-lite"
Expand Down Expand Up @@ -224,7 +223,7 @@ func init() {
addExample(wallet.MEChainMsg)

// used in gateway
addExample(commontypes.PaddedByteIndex(10))
addExample(types.PaddedByteIndex(10))

// used in market
addExample(filestore.Path("/some/path"))
Expand Down
11 changes: 5 additions & 6 deletions venus-shared/api/gateway/v1/market_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-storage/storage"
types2 "github.com/ipfs-force-community/venus-common-utils/types"
"github.com/ipfs/go-cid"

"github.com/filecoin-project/venus/venus-shared/types"
gtypes "github.com/filecoin-project/venus/venus-shared/types/gateway"
"github.com/ipfs/go-cid"
)

type IMarketEvent interface {
ListMarketConnectionsState(ctx context.Context) ([]gtypes.MarketConnectionState, error) //perm:admin
IsUnsealed(ctx context.Context, miner address.Address, pieceCid cid.Cid, sector storage.SectorRef, offset types2.PaddedByteIndex, size abi.PaddedPieceSize) (bool, error) //perm:admin
SectorsUnsealPiece(ctx context.Context, miner address.Address, pieceCid cid.Cid, sector storage.SectorRef, offset types2.PaddedByteIndex, size abi.PaddedPieceSize, dest string) error //perm:admin
ListMarketConnectionsState(ctx context.Context) ([]gtypes.MarketConnectionState, error) //perm:admin
IsUnsealed(ctx context.Context, miner address.Address, pieceCid cid.Cid, sector storage.SectorRef, offset types.PaddedByteIndex, size abi.PaddedPieceSize) (bool, error) //perm:admin
SectorsUnsealPiece(ctx context.Context, miner address.Address, pieceCid cid.Cid, sector storage.SectorRef, offset types.PaddedByteIndex, size abi.PaddedPieceSize, dest string) error //perm:admin

ResponseMarketEvent(ctx context.Context, resp *gtypes.ResponseEvent) error //perm:read
ListenMarketEvent(ctx context.Context, policy *gtypes.MarketRegisterPolicy) (<-chan *gtypes.RequestEvent, error) //perm:read
Expand Down
15 changes: 7 additions & 8 deletions venus-shared/api/gateway/v1/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions venus-shared/types/gateway/market_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-storage/storage"
types2 "github.com/ipfs-force-community/venus-common-utils/types"
"github.com/filecoin-project/venus/venus-shared/types"
"github.com/ipfs/go-cid"
)

Expand All @@ -15,7 +15,7 @@ type MarketRegisterPolicy struct {
type IsUnsealRequest struct {
PieceCid cid.Cid
Sector storage.SectorRef
Offset types2.PaddedByteIndex
Offset types.PaddedByteIndex
Size abi.PaddedPieceSize
}

Expand All @@ -25,7 +25,7 @@ type IsUnsealResponse struct {
type UnsealRequest struct {
PieceCid cid.Cid
Sector storage.SectorRef
Offset types2.PaddedByteIndex
Offset types.PaddedByteIndex
Size abi.PaddedPieceSize
Dest string
}
Expand Down
22 changes: 22 additions & 0 deletions venus-shared/types/padded_byte.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package types

import (
"github.com/filecoin-project/go-state-types/abi"
"golang.org/x/xerrors"
)

type UnpaddedByteIndex uint64

func (i UnpaddedByteIndex) Padded() PaddedByteIndex {
return PaddedByteIndex(abi.UnpaddedPieceSize(i).Padded())
}

func (i UnpaddedByteIndex) Valid() error {
if i%127 != 0 {
return xerrors.Errorf("unpadded byte index must be a multiple of 127")
}

return nil
}

type PaddedByteIndex uint64