Skip to content

Commit 631849c

Browse files
authored
type: venus-shared: add pad byte index (#4777)
* type: venus-shared: add pad byte index
1 parent ebc5d82 commit 631849c

File tree

5 files changed

+38
-19
lines changed

5 files changed

+38
-19
lines changed

venus-devtool/api-gen/example.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"github.com/filecoin-project/go-state-types/abi"
1818
"github.com/filecoin-project/go-state-types/crypto"
1919
"github.com/filecoin-project/go-state-types/exitcode"
20-
commontypes "github.com/ipfs-force-community/venus-common-utils/types"
2120
"github.com/ipfs/go-cid"
2221
"github.com/ipfs/go-graphsync"
2322
textselector "github.com/ipld/go-ipld-selector-text-lite"
@@ -224,7 +223,7 @@ func init() {
224223
addExample(wallet.MEChainMsg)
225224

226225
// used in gateway
227-
addExample(commontypes.PaddedByteIndex(10))
226+
addExample(types.PaddedByteIndex(10))
228227

229228
// used in market
230229
addExample(filestore.Path("/some/path"))

venus-shared/api/gateway/v1/market_event.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ import (
66
"github.com/filecoin-project/go-address"
77
"github.com/filecoin-project/go-state-types/abi"
88
"github.com/filecoin-project/specs-storage/storage"
9-
types2 "github.com/ipfs-force-community/venus-common-utils/types"
10-
"github.com/ipfs/go-cid"
11-
9+
"github.com/filecoin-project/venus/venus-shared/types"
1210
gtypes "github.com/filecoin-project/venus/venus-shared/types/gateway"
11+
"github.com/ipfs/go-cid"
1312
)
1413

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

2019
ResponseMarketEvent(ctx context.Context, resp *gtypes.ResponseEvent) error //perm:read
2120
ListenMarketEvent(ctx context.Context, policy *gtypes.MarketRegisterPolicy) (<-chan *gtypes.RequestEvent, error) //perm:read

venus-shared/api/gateway/v1/proxy_gen.go

+7-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

venus-shared/types/gateway/market_event.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"github.com/filecoin-project/go-address"
55
"github.com/filecoin-project/go-state-types/abi"
66
"github.com/filecoin-project/specs-storage/storage"
7-
types2 "github.com/ipfs-force-community/venus-common-utils/types"
7+
"github.com/filecoin-project/venus/venus-shared/types"
88
"github.com/ipfs/go-cid"
99
)
1010

@@ -15,7 +15,7 @@ type MarketRegisterPolicy struct {
1515
type IsUnsealRequest struct {
1616
PieceCid cid.Cid
1717
Sector storage.SectorRef
18-
Offset types2.PaddedByteIndex
18+
Offset types.PaddedByteIndex
1919
Size abi.PaddedPieceSize
2020
}
2121

@@ -25,7 +25,7 @@ type IsUnsealResponse struct {
2525
type UnsealRequest struct {
2626
PieceCid cid.Cid
2727
Sector storage.SectorRef
28-
Offset types2.PaddedByteIndex
28+
Offset types.PaddedByteIndex
2929
Size abi.PaddedPieceSize
3030
Dest string
3131
}

venus-shared/types/padded_byte.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package types
2+
3+
import (
4+
"github.com/filecoin-project/go-state-types/abi"
5+
"golang.org/x/xerrors"
6+
)
7+
8+
type UnpaddedByteIndex uint64
9+
10+
func (i UnpaddedByteIndex) Padded() PaddedByteIndex {
11+
return PaddedByteIndex(abi.UnpaddedPieceSize(i).Padded())
12+
}
13+
14+
func (i UnpaddedByteIndex) Valid() error {
15+
if i%127 != 0 {
16+
return xerrors.Errorf("unpadded byte index must be a multiple of 127")
17+
}
18+
19+
return nil
20+
}
21+
22+
type PaddedByteIndex uint64

0 commit comments

Comments
 (0)