Skip to content

Commit

Permalink
feat: upgrade market-event api
Browse files Browse the repository at this point in the history
  • Loading branch information
diwufeiwen committed Feb 9, 2023
1 parent 95604cc commit 61e06b8
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 34 deletions.
5 changes: 5 additions & 0 deletions venus-devtool/api-gen/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ func init() {

// used in market
addExample(filestore.Path("/some/path"))
params, _ := json.Marshal(&market.FsTransfer{Path: "/path"})
addExample(&market.Transfer{
Type: market.PiecesTransferFs,
Params: params,
})

clientDataSelector := client.DataSelector("/ipld/a/b/c")
addExample(clientDataSelector)
Expand Down
9 changes: 4 additions & 5 deletions venus-shared/api/gateway/v2/market_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import (

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-storage/storage"

"github.com/ipfs/go-cid"

"github.com/filecoin-project/venus/venus-shared/types"
gtypes "github.com/filecoin-project/venus/venus-shared/types/gateway"
mktypes "github.com/filecoin-project/venus/venus-shared/types/market"
)

type IMarketEvent interface {
Expand All @@ -19,9 +18,9 @@ type IMarketEvent interface {
}

type IMarketClient interface {
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
ListMarketConnectionsState(ctx context.Context) ([]gtypes.MarketConnectionState, error) //perm:admin
IsUnsealed(ctx context.Context, miner address.Address, pieceCid cid.Cid, sid abi.SectorNumber, offset types.PaddedByteIndex, size abi.PaddedPieceSize) (bool, error) //perm:admin
SectorsUnsealPiece(ctx context.Context, miner address.Address, pieceCid cid.Cid, sid abi.SectorNumber, offset types.PaddedByteIndex, size abi.PaddedPieceSize, transfer *mktypes.Transfer) error //perm:admin
}

type IMarketServiceProvider interface {
Expand Down
21 changes: 6 additions & 15 deletions venus-shared/api/gateway/v2/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,7 @@ Inputs:
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
{
"ID": {
"Miner": 1000,
"Number": 9
},
"ProofType": 8
},
9,
10,
1032
]
Expand Down Expand Up @@ -116,16 +110,13 @@ Inputs:
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
{
"ID": {
"Miner": 1000,
"Number": 9
},
"ProofType": 8
},
9,
10,
1032,
"string value"
{
"Type": "fs",
"Params": "eyJQYXRoIjoiL3BhdGgifQ=="
}
]
```

Expand Down
6 changes: 3 additions & 3 deletions venus-shared/api/gateway/v2/mock/mock_igateway.go

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

12 changes: 6 additions & 6 deletions venus-shared/api/gateway/v2/proxy_gen.go

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

14 changes: 9 additions & 5 deletions venus-shared/types/gateway/market_event.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package gateway

import (
"github.com/filecoin-project/venus/venus-shared/types/market"
"github.com/ipfs/go-cid"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-storage/storage"

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

type MarketRegisterPolicy struct {
Expand All @@ -14,7 +16,8 @@ type MarketRegisterPolicy struct {

type IsUnsealRequest struct {
PieceCid cid.Cid
Sector storage.SectorRef
Miner address.Address
Sid abi.SectorNumber
Offset types.PaddedByteIndex
Size abi.PaddedPieceSize
}
Expand All @@ -23,10 +26,11 @@ type IsUnsealResponse struct{}

type UnsealRequest struct {
PieceCid cid.Cid
Sector storage.SectorRef
Miner address.Address
Sid abi.SectorNumber
Offset types.PaddedByteIndex
Size abi.PaddedPieceSize
Dest string
Transfer market.Transfer
}

type UnsealResponse struct{}
Expand Down
31 changes: 31 additions & 0 deletions venus-shared/types/market/piece_transfer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package market

const (
PiecesTransferS3 = "s3"
PiecesTransferFs = "fs"
)

type FsTransfer struct {
Path string
}

type S3Transfer struct {
EndPoint string
Bucket string
SubDir string

AccessKey string
SecretKey string
Token string

Key string
}

// Transfer has the parameters for a data transfer
type Transfer struct {
// The type of transfer eg "http"
Type string
// A byte array containing marshalled data specific to the transfer type
// eg a JSON encoded struct { URL: "<url>", Headers: {...} }
Params []byte
}

0 comments on commit 61e06b8

Please sign in to comment.