diff --git a/venus-devtool/api-gen/example.go b/venus-devtool/api-gen/example.go index e5491d3fa3..29b3cbf8f8 100644 --- a/venus-devtool/api-gen/example.go +++ b/venus-devtool/api-gen/example.go @@ -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) diff --git a/venus-shared/api/gateway/v2/market_event.go b/venus-shared/api/gateway/v2/market_event.go index e01af80b2c..5a7f0b30fa 100644 --- a/venus-shared/api/gateway/v2/market_event.go +++ b/venus-shared/api/gateway/v2/market_event.go @@ -11,6 +11,7 @@ import ( "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 { @@ -19,9 +20,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, 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, transfer *mktypes.Transfer) error //perm:admin } type IMarketServiceProvider interface { diff --git a/venus-shared/api/gateway/v2/method.md b/venus-shared/api/gateway/v2/method.md index 897ae680e2..18d88d9fa1 100644 --- a/venus-shared/api/gateway/v2/method.md +++ b/venus-shared/api/gateway/v2/method.md @@ -125,7 +125,10 @@ Inputs: }, 10, 1032, - "string value" + { + "Type": "fs", + "Params": "eyJQYXRoIjoiL3BhdGgifQ==" + } ] ``` diff --git a/venus-shared/api/gateway/v2/mock/mock_igateway.go b/venus-shared/api/gateway/v2/mock/mock_igateway.go index 4e4391e9e4..2de67ef6ac 100644 --- a/venus-shared/api/gateway/v2/mock/mock_igateway.go +++ b/venus-shared/api/gateway/v2/mock/mock_igateway.go @@ -16,6 +16,7 @@ import ( storage "github.com/filecoin-project/specs-storage/storage" types "github.com/filecoin-project/venus/venus-shared/types" gateway "github.com/filecoin-project/venus/venus-shared/types/gateway" + market "github.com/filecoin-project/venus/venus-shared/types/market" gomock "github.com/golang/mock/gomock" cid "github.com/ipfs/go-cid" ) @@ -264,7 +265,7 @@ func (mr *MockIGatewayMockRecorder) ResponseWalletEvent(arg0, arg1 interface{}) } // SectorsUnsealPiece mocks base method. -func (m *MockIGateway) SectorsUnsealPiece(arg0 context.Context, arg1 address.Address, arg2 cid.Cid, arg3 storage.SectorRef, arg4 types.PaddedByteIndex, arg5 abi.PaddedPieceSize, arg6 string) error { +func (m *MockIGateway) SectorsUnsealPiece(arg0 context.Context, arg1 address.Address, arg2 cid.Cid, arg3 storage.SectorRef, arg4 types.PaddedByteIndex, arg5 abi.PaddedPieceSize, arg6 *market.Transfer) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SectorsUnsealPiece", arg0, arg1, arg2, arg3, arg4, arg5, arg6) ret0, _ := ret[0].(error) diff --git a/venus-shared/api/gateway/v2/proxy_gen.go b/venus-shared/api/gateway/v2/proxy_gen.go index b89a4087c0..a1e1b3a54c 100644 --- a/venus-shared/api/gateway/v2/proxy_gen.go +++ b/venus-shared/api/gateway/v2/proxy_gen.go @@ -14,6 +14,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors/builtin" "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 IProofClientStruct struct { @@ -108,9 +109,9 @@ type IWalletEventStruct struct { type IMarketClientStruct struct { Internal struct { - IsUnsealed func(ctx context.Context, miner address.Address, pieceCid cid.Cid, sector storage.SectorRef, offset types.PaddedByteIndex, size abi.PaddedPieceSize) (bool, error) `perm:"admin"` - ListMarketConnectionsState func(ctx context.Context) ([]gtypes.MarketConnectionState, error) `perm:"admin"` - SectorsUnsealPiece func(ctx context.Context, miner address.Address, pieceCid cid.Cid, sector storage.SectorRef, offset types.PaddedByteIndex, size abi.PaddedPieceSize, dest string) error `perm:"admin"` + IsUnsealed func(ctx context.Context, miner address.Address, pieceCid cid.Cid, sector storage.SectorRef, offset types.PaddedByteIndex, size abi.PaddedPieceSize) (bool, error) `perm:"admin"` + ListMarketConnectionsState func(ctx context.Context) ([]gtypes.MarketConnectionState, error) `perm:"admin"` + SectorsUnsealPiece func(ctx context.Context, miner address.Address, pieceCid cid.Cid, sector storage.SectorRef, offset types.PaddedByteIndex, size abi.PaddedPieceSize, transfer *mktypes.Transfer) error `perm:"admin"` } } @@ -120,7 +121,7 @@ func (s *IMarketClientStruct) IsUnsealed(p0 context.Context, p1 address.Address, func (s *IMarketClientStruct) ListMarketConnectionsState(p0 context.Context) ([]gtypes.MarketConnectionState, error) { return s.Internal.ListMarketConnectionsState(p0) } -func (s *IMarketClientStruct) SectorsUnsealPiece(p0 context.Context, p1 address.Address, p2 cid.Cid, p3 storage.SectorRef, p4 types.PaddedByteIndex, p5 abi.PaddedPieceSize, p6 string) error { +func (s *IMarketClientStruct) SectorsUnsealPiece(p0 context.Context, p1 address.Address, p2 cid.Cid, p3 storage.SectorRef, p4 types.PaddedByteIndex, p5 abi.PaddedPieceSize, p6 *mktypes.Transfer) error { return s.Internal.SectorsUnsealPiece(p0, p1, p2, p3, p4, p5, p6) } diff --git a/venus-shared/types/market/piece_transfer.go b/venus-shared/types/market/piece_transfer.go new file mode 100644 index 0000000000..0d3065f7ed --- /dev/null +++ b/venus-shared/types/market/piece_transfer.go @@ -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: "", Headers: {...} } + Params []byte +}