diff --git a/venus-devtool/api-gen/example.go b/venus-devtool/api-gen/example.go index ed2e307a44..708b5d70da 100644 --- a/venus-devtool/api-gen/example.go +++ b/venus-devtool/api-gen/example.go @@ -271,6 +271,8 @@ func init() { uuidTmp := auuid.MustParse("102334ec-35a3-4b36-be9f-02883844503a") addExample(&uuidTmp) + addExample(market.DirectDealState(1)) + // eth types ethint := types.EthUint64(5) addExample(ethint) diff --git a/venus-shared/api/market/v1/api.go b/venus-shared/api/market/v1/api.go index 7062a63cf9..8ff669368c 100644 --- a/venus-shared/api/market/v1/api.go +++ b/venus-shared/api/market/v1/api.go @@ -4,6 +4,7 @@ import ( "context" "time" + "github.com/google/uuid" "github.com/ipfs/go-cid" "github.com/libp2p/go-libp2p/core/peer" @@ -165,6 +166,8 @@ type IMarket interface { ReleaseDeals(ctx context.Context, miner address.Address, deals []abi.DealID) error //perm:write GetUnPackedDeals(ctx context.Context, miner address.Address, spec *market.GetDealSpec) ([]*market.DealInfoIncludePath, error) //perm:read UpdateStorageDealStatus(ctx context.Context, dealProposalCid cid.Cid, state storagemarket.StorageDealStatus, pieceState market.PieceStatus) error //perm:write + AssignDeals(ctx context.Context, sid abi.SectorID, ssize abi.SectorSize, spec *market.GetDealSpec) ([]*market.DealInfoV2, error) //perm:write + ReleaseDirectDeals(ctx context.Context, miner address.Address, allocationIDs []types.AllocationId) error //perm:write // market event ResponseMarketEvent(ctx context.Context, resp *gateway.ResponseEvent) error //perm:read ListenMarketEvent(ctx context.Context, policy *gateway.MarketRegisterPolicy) (<-chan *gateway.RequestEvent, error) //perm:read @@ -188,5 +191,11 @@ type IMarket interface { // todo address undefined is invalid, it is currently not possible to directly associate an order with a miner GetRetrievalDealStatistic(ctx context.Context, miner address.Address) (*market.RetrievalDealStatistic, error) //perm:read + // ImportDirectDeal import direct deals + ImportDirectDeal(ctx context.Context, deal *market.DirectDealParams) error //perm:write + GetDirectDeal(ctx context.Context, id uuid.UUID) (*market.DirectDeal, error) //perm:read + GetDirectDealByAllocationID(ctx context.Context, id types.AllocationId) (*market.DirectDeal, error) //perm:read + ListDirectDeals(ctx context.Context, queryParams market.DirectDealQueryParams) ([]*market.DirectDeal, error) //perm:read + api.Version } diff --git a/venus-shared/api/market/v1/method.md b/venus-shared/api/market/v1/method.md index f0134fba44..c638fe2a79 100644 --- a/venus-shared/api/market/v1/method.md +++ b/venus-shared/api/market/v1/method.md @@ -14,6 +14,7 @@ curl http://:/rpc/v1 -X POST -H "Content-Type: application/json" -H " * [ActorUpsert](#actorupsert) * [AddFsPieceStorage](#addfspiecestorage) * [AddS3PieceStorage](#adds3piecestorage) + * [AssignDeals](#assigndeals) * [AssignUnPackedDeals](#assignunpackeddeals) * [DagstoreDestroyShard](#dagstoredestroyshard) * [DagstoreGC](#dagstoregc) @@ -48,10 +49,14 @@ curl http://:/rpc/v1 -X POST -H "Content-Type: application/json" -H " * [DealsSetPieceCidBlocklist](#dealssetpiececidblocklist) * [DealsSetPublishMsgPeriod](#dealssetpublishmsgperiod) * [GetDeals](#getdeals) + * [GetDirectDeal](#getdirectdeal) + * [GetDirectDealByAllocationID](#getdirectdealbyallocationid) * [GetRetrievalDealStatistic](#getretrievaldealstatistic) * [GetStorageDealStatistic](#getstoragedealstatistic) * [GetUnPackedDeals](#getunpackeddeals) * [ID](#id) + * [ImportDirectDeal](#importdirectdeal) + * [ListDirectDeals](#listdirectdeals) * [ListPieceStorageInfos](#listpiecestorageinfos) * [ListenMarketEvent](#listenmarketevent) * [MarkDealsAsPacking](#markdealsaspacking) @@ -96,6 +101,7 @@ curl http://:/rpc/v1 -X POST -H "Content-Type: application/json" -H " * [PiecesListCidInfos](#pieceslistcidinfos) * [PiecesListPieces](#pieceslistpieces) * [ReleaseDeals](#releasedeals) + * [ReleaseDirectDeals](#releasedirectdeals) * [RemovePieceStorage](#removepiecestorage) * [ResponseMarketEvent](#responsemarketevent) * [SectorGetExpectedSealDuration](#sectorgetexpectedsealduration) @@ -220,6 +226,56 @@ Inputs: Response: `{}` +### AssignDeals + + +Perms: write + +Inputs: +```json +[ + { + "Miner": 1000, + "Number": 9 + }, + 34359738368, + { + "MaxPiece": 123, + "MaxPieceSize": 42, + "MinPiece": 123, + "MinPieceSize": 42, + "MinUsedSpace": 42, + "StartEpoch": 10101, + "EndEpoch": 10101, + "SectorExpiration": 10101 + } +] +``` + +Response: +```json +[ + { + "DealID": 5432, + "PublishCid": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "AllocationID": 0, + "PieceCID": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "PieceSize": 1032, + "Client": "f01234", + "Provider": "f01234", + "Offset": 1032, + "Length": 1032, + "PayloadSize": 42, + "StartEpoch": 10101, + "EndEpoch": 10101 + } +] +``` + ### AssignUnPackedDeals @@ -962,6 +1018,80 @@ Response: ] ``` +### GetDirectDeal + + +Perms: read + +Inputs: +```json +[ + "07070707-0707-0707-0707-070707070707" +] +``` + +Response: +```json +{ + "ID": "07070707-0707-0707-0707-070707070707", + "PieceCID": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "PieceSize": 1032, + "Client": "f01234", + "Provider": "f01234", + "PayloadSize": 42, + "State": 1, + "AllocationID": 42, + "ClaimID": 42, + "SectorID": 9, + "Offset": 1032, + "Length": 1032, + "StartEpoch": 10101, + "EndEpoch": 10101, + "Message": "string value", + "CreatedAt": 42, + "UpdatedAt": 42 +} +``` + +### GetDirectDealByAllocationID + + +Perms: read + +Inputs: +```json +[ + 0 +] +``` + +Response: +```json +{ + "ID": "07070707-0707-0707-0707-070707070707", + "PieceCID": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "PieceSize": 1032, + "Client": "f01234", + "Provider": "f01234", + "PayloadSize": 42, + "State": 1, + "AllocationID": 42, + "ClaimID": 42, + "SectorID": 9, + "Offset": 1032, + "Length": 1032, + "StartEpoch": 10101, + "EndEpoch": 10101, + "Message": "string value", + "CreatedAt": 42, + "UpdatedAt": 42 +} +``` + ### GetRetrievalDealStatistic GetRetrievalDealStatistic get retrieval deal statistic information todo address undefined is invalid, it is currently not possible to directly associate an order with a miner @@ -1069,6 +1199,83 @@ Inputs: `[]` Response: `"12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf"` +### ImportDirectDeal +ImportDirectDeal import direct deals + + +Perms: write + +Inputs: +```json +[ + { + "SkipCommP": true, + "NoCopyCarFile": true, + "SkipGenerateIndex": true, + "DealParams": [ + { + "FilePath": "string value", + "PayloadSize": 42, + "DealUUID": "07070707-0707-0707-0707-070707070707", + "AllocationID": 42, + "PieceCID": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Client": "f01234" + } + ] + } +] +``` + +Response: `{}` + +### ListDirectDeals + + +Perms: read + +Inputs: +```json +[ + { + "Provider": "f01234", + "Client": "f01234", + "State": 1, + "Offset": 123, + "Limit": 123, + "Asc": true + } +] +``` + +Response: +```json +[ + { + "ID": "07070707-0707-0707-0707-070707070707", + "PieceCID": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "PieceSize": 1032, + "Client": "f01234", + "Provider": "f01234", + "PayloadSize": 42, + "State": 1, + "AllocationID": 42, + "ClaimID": 42, + "SectorID": 9, + "Offset": 1032, + "Length": 1032, + "StartEpoch": 10101, + "EndEpoch": 10101, + "Message": "string value", + "CreatedAt": 42, + "UpdatedAt": 42 + } +] +``` + ### ListPieceStorageInfos @@ -2430,6 +2637,23 @@ Inputs: Response: `{}` +### ReleaseDirectDeals + + +Perms: write + +Inputs: +```json +[ + "f01234", + [ + 0 + ] +] +``` + +Response: `{}` + ### RemovePieceStorage diff --git a/venus-shared/api/market/v1/mock/mock_imarket.go b/venus-shared/api/market/v1/mock/mock_imarket.go index caad5fd3d5..1ca73a3b75 100644 --- a/venus-shared/api/market/v1/mock/mock_imarket.go +++ b/venus-shared/api/market/v1/mock/mock_imarket.go @@ -16,11 +16,13 @@ import ( abi "github.com/filecoin-project/go-state-types/abi" big "github.com/filecoin-project/go-state-types/big" paych "github.com/filecoin-project/go-state-types/builtin/v8/paych" + verifreg "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" types "github.com/filecoin-project/venus/venus-shared/actors/types" types0 "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" + uuid "github.com/google/uuid" cid "github.com/ipfs/go-cid" peer "github.com/libp2p/go-libp2p/core/peer" ) @@ -150,6 +152,21 @@ func (mr *MockIMarketMockRecorder) AddS3PieceStorage(arg0, arg1, arg2, arg3, arg return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddS3PieceStorage", reflect.TypeOf((*MockIMarket)(nil).AddS3PieceStorage), arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) } +// AssignDeals mocks base method. +func (m *MockIMarket) AssignDeals(arg0 context.Context, arg1 abi.SectorID, arg2 abi.SectorSize, arg3 *market.GetDealSpec) ([]*market.DealInfoV2, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AssignDeals", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].([]*market.DealInfoV2) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// AssignDeals indicates an expected call of AssignDeals. +func (mr *MockIMarketMockRecorder) AssignDeals(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AssignDeals", reflect.TypeOf((*MockIMarket)(nil).AssignDeals), arg0, arg1, arg2, arg3) +} + // AssignUnPackedDeals mocks base method. func (m *MockIMarket) AssignUnPackedDeals(arg0 context.Context, arg1 abi.SectorID, arg2 abi.SectorSize, arg3 *market.GetDealSpec) ([]*market.DealInfoIncludePath, error) { m.ctrl.T.Helper() @@ -644,6 +661,36 @@ func (mr *MockIMarketMockRecorder) GetDeals(arg0, arg1, arg2, arg3 interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDeals", reflect.TypeOf((*MockIMarket)(nil).GetDeals), arg0, arg1, arg2, arg3) } +// GetDirectDeal mocks base method. +func (m *MockIMarket) GetDirectDeal(arg0 context.Context, arg1 uuid.UUID) (*market.DirectDeal, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetDirectDeal", arg0, arg1) + ret0, _ := ret[0].(*market.DirectDeal) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetDirectDeal indicates an expected call of GetDirectDeal. +func (mr *MockIMarketMockRecorder) GetDirectDeal(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDirectDeal", reflect.TypeOf((*MockIMarket)(nil).GetDirectDeal), arg0, arg1) +} + +// GetDirectDealByAllocationID mocks base method. +func (m *MockIMarket) GetDirectDealByAllocationID(arg0 context.Context, arg1 verifreg.AllocationId) (*market.DirectDeal, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetDirectDealByAllocationID", arg0, arg1) + ret0, _ := ret[0].(*market.DirectDeal) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetDirectDealByAllocationID indicates an expected call of GetDirectDealByAllocationID. +func (mr *MockIMarketMockRecorder) GetDirectDealByAllocationID(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDirectDealByAllocationID", reflect.TypeOf((*MockIMarket)(nil).GetDirectDealByAllocationID), arg0, arg1) +} + // GetRetrievalDealStatistic mocks base method. func (m *MockIMarket) GetRetrievalDealStatistic(arg0 context.Context, arg1 address.Address) (*market.RetrievalDealStatistic, error) { m.ctrl.T.Helper() @@ -704,6 +751,35 @@ func (mr *MockIMarketMockRecorder) ID(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ID", reflect.TypeOf((*MockIMarket)(nil).ID), arg0) } +// ImportDirectDeal mocks base method. +func (m *MockIMarket) ImportDirectDeal(arg0 context.Context, arg1 *market.DirectDealParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ImportDirectDeal", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// ImportDirectDeal indicates an expected call of ImportDirectDeal. +func (mr *MockIMarketMockRecorder) ImportDirectDeal(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImportDirectDeal", reflect.TypeOf((*MockIMarket)(nil).ImportDirectDeal), arg0, arg1) +} + +// ListDirectDeals mocks base method. +func (m *MockIMarket) ListDirectDeals(arg0 context.Context, arg1 market.DirectDealQueryParams) ([]*market.DirectDeal, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListDirectDeals", arg0, arg1) + ret0, _ := ret[0].([]*market.DirectDeal) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListDirectDeals indicates an expected call of ListDirectDeals. +func (mr *MockIMarketMockRecorder) ListDirectDeals(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListDirectDeals", reflect.TypeOf((*MockIMarket)(nil).ListDirectDeals), arg0, arg1) +} + // ListPieceStorageInfos mocks base method. func (m *MockIMarket) ListPieceStorageInfos(arg0 context.Context) market.PieceStorageInfos { m.ctrl.T.Helper() @@ -1350,6 +1426,20 @@ func (mr *MockIMarketMockRecorder) ReleaseDeals(arg0, arg1, arg2 interface{}) *g return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReleaseDeals", reflect.TypeOf((*MockIMarket)(nil).ReleaseDeals), arg0, arg1, arg2) } +// ReleaseDirectDeals mocks base method. +func (m *MockIMarket) ReleaseDirectDeals(arg0 context.Context, arg1 address.Address, arg2 []verifreg.AllocationId) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReleaseDirectDeals", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// ReleaseDirectDeals indicates an expected call of ReleaseDirectDeals. +func (mr *MockIMarketMockRecorder) ReleaseDirectDeals(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReleaseDirectDeals", reflect.TypeOf((*MockIMarket)(nil).ReleaseDirectDeals), arg0, arg1, arg2) +} + // RemovePieceStorage mocks base method. func (m *MockIMarket) RemovePieceStorage(arg0 context.Context, arg1 string) error { m.ctrl.T.Helper() diff --git a/venus-shared/api/market/v1/proxy_gen.go b/venus-shared/api/market/v1/proxy_gen.go index 329d04ef68..87b82f44bf 100644 --- a/venus-shared/api/market/v1/proxy_gen.go +++ b/venus-shared/api/market/v1/proxy_gen.go @@ -12,6 +12,7 @@ import ( "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/builtin/v8/paych" + "github.com/google/uuid" cid "github.com/ipfs/go-cid" "github.com/libp2p/go-libp2p/core/peer" @@ -29,6 +30,7 @@ type IMarketStruct struct { ActorUpsert func(context.Context, market.User) (bool, error) `perm:"admin"` AddFsPieceStorage func(ctx context.Context, name string, path string, readonly bool) error `perm:"admin"` AddS3PieceStorage func(ctx context.Context, name, endpoit, bucket, subdir, accessKey, secretKey, token string, readonly bool) error `perm:"admin"` + AssignDeals func(ctx context.Context, sid abi.SectorID, ssize abi.SectorSize, spec *market.GetDealSpec) ([]*market.DealInfoV2, error) `perm:"write"` AssignUnPackedDeals func(ctx context.Context, sid abi.SectorID, ssize abi.SectorSize, spec *market.GetDealSpec) ([]*market.DealInfoIncludePath, error) `perm:"write"` DagstoreDestroyShard func(ctx context.Context, key string) error `perm:"admin"` DagstoreGC func(ctx context.Context) ([]market.DagstoreShardResult, error) `perm:"admin"` @@ -63,10 +65,14 @@ type IMarketStruct struct { DealsSetPieceCidBlocklist func(context.Context, address.Address, []cid.Cid) error `perm:"write"` DealsSetPublishMsgPeriod func(context.Context, address.Address, time.Duration) error `perm:"write"` GetDeals func(ctx context.Context, miner address.Address, pageIndex, pageSize int) ([]*market.DealInfo, error) `perm:"read"` + GetDirectDeal func(ctx context.Context, id uuid.UUID) (*market.DirectDeal, error) `perm:"read"` + GetDirectDealByAllocationID func(ctx context.Context, id types.AllocationId) (*market.DirectDeal, error) `perm:"read"` GetRetrievalDealStatistic func(ctx context.Context, miner address.Address) (*market.RetrievalDealStatistic, error) `perm:"read"` GetStorageDealStatistic func(ctx context.Context, miner address.Address) (*market.StorageDealStatistic, error) `perm:"read"` GetUnPackedDeals func(ctx context.Context, miner address.Address, spec *market.GetDealSpec) ([]*market.DealInfoIncludePath, error) `perm:"read"` ID func(context.Context) (peer.ID, error) `perm:"read"` + ImportDirectDeal func(ctx context.Context, deal *market.DirectDealParams) error `perm:"write"` + ListDirectDeals func(ctx context.Context, queryParams market.DirectDealQueryParams) ([]*market.DirectDeal, error) `perm:"read"` ListPieceStorageInfos func(ctx context.Context) market.PieceStorageInfos `perm:"read"` ListenMarketEvent func(ctx context.Context, policy *gateway.MarketRegisterPolicy) (<-chan *gateway.RequestEvent, error) `perm:"read"` MarkDealsAsPacking func(ctx context.Context, miner address.Address, deals []abi.DealID) error `perm:"write"` @@ -111,6 +117,7 @@ type IMarketStruct struct { PiecesListCidInfos func(ctx context.Context) ([]cid.Cid, error) `perm:"read"` PiecesListPieces func(ctx context.Context) ([]cid.Cid, error) `perm:"read"` ReleaseDeals func(ctx context.Context, miner address.Address, deals []abi.DealID) error `perm:"write"` + ReleaseDirectDeals func(ctx context.Context, miner address.Address, allocationIDs []types.AllocationId) error `perm:"write"` RemovePieceStorage func(ctx context.Context, name string) error `perm:"admin"` ResponseMarketEvent func(ctx context.Context, resp *gateway.ResponseEvent) error `perm:"read"` SectorGetExpectedSealDuration func(context.Context, address.Address) (time.Duration, error) `perm:"read"` @@ -143,6 +150,9 @@ func (s *IMarketStruct) AddFsPieceStorage(p0 context.Context, p1 string, p2 stri func (s *IMarketStruct) AddS3PieceStorage(p0 context.Context, p1, p2, p3, p4, p5, p6, p7 string, p8 bool) error { return s.Internal.AddS3PieceStorage(p0, p1, p2, p3, p4, p5, p6, p7, p8) } +func (s *IMarketStruct) AssignDeals(p0 context.Context, p1 abi.SectorID, p2 abi.SectorSize, p3 *market.GetDealSpec) ([]*market.DealInfoV2, error) { + return s.Internal.AssignDeals(p0, p1, p2, p3) +} func (s *IMarketStruct) AssignUnPackedDeals(p0 context.Context, p1 abi.SectorID, p2 abi.SectorSize, p3 *market.GetDealSpec) ([]*market.DealInfoIncludePath, error) { return s.Internal.AssignUnPackedDeals(p0, p1, p2, p3) } @@ -245,6 +255,12 @@ func (s *IMarketStruct) DealsSetPublishMsgPeriod(p0 context.Context, p1 address. func (s *IMarketStruct) GetDeals(p0 context.Context, p1 address.Address, p2, p3 int) ([]*market.DealInfo, error) { return s.Internal.GetDeals(p0, p1, p2, p3) } +func (s *IMarketStruct) GetDirectDeal(p0 context.Context, p1 uuid.UUID) (*market.DirectDeal, error) { + return s.Internal.GetDirectDeal(p0, p1) +} +func (s *IMarketStruct) GetDirectDealByAllocationID(p0 context.Context, p1 types.AllocationId) (*market.DirectDeal, error) { + return s.Internal.GetDirectDealByAllocationID(p0, p1) +} func (s *IMarketStruct) GetRetrievalDealStatistic(p0 context.Context, p1 address.Address) (*market.RetrievalDealStatistic, error) { return s.Internal.GetRetrievalDealStatistic(p0, p1) } @@ -255,6 +271,12 @@ func (s *IMarketStruct) GetUnPackedDeals(p0 context.Context, p1 address.Address, return s.Internal.GetUnPackedDeals(p0, p1, p2) } func (s *IMarketStruct) ID(p0 context.Context) (peer.ID, error) { return s.Internal.ID(p0) } +func (s *IMarketStruct) ImportDirectDeal(p0 context.Context, p1 *market.DirectDealParams) error { + return s.Internal.ImportDirectDeal(p0, p1) +} +func (s *IMarketStruct) ListDirectDeals(p0 context.Context, p1 market.DirectDealQueryParams) ([]*market.DirectDeal, error) { + return s.Internal.ListDirectDeals(p0, p1) +} func (s *IMarketStruct) ListPieceStorageInfos(p0 context.Context) market.PieceStorageInfos { return s.Internal.ListPieceStorageInfos(p0) } @@ -387,6 +409,9 @@ func (s *IMarketStruct) PiecesListPieces(p0 context.Context) ([]cid.Cid, error) func (s *IMarketStruct) ReleaseDeals(p0 context.Context, p1 address.Address, p2 []abi.DealID) error { return s.Internal.ReleaseDeals(p0, p1, p2) } +func (s *IMarketStruct) ReleaseDirectDeals(p0 context.Context, p1 address.Address, p2 []types.AllocationId) error { + return s.Internal.ReleaseDirectDeals(p0, p1, p2) +} func (s *IMarketStruct) RemovePieceStorage(p0 context.Context, p1 string) error { return s.Internal.RemovePieceStorage(p0, p1) } diff --git a/venus-shared/types/market/assigner_type.go b/venus-shared/types/market/assigner_type.go index dfb3f259d0..48588793c4 100644 --- a/venus-shared/types/market/assigner_type.go +++ b/venus-shared/types/market/assigner_type.go @@ -3,6 +3,7 @@ package market import ( "github.com/ipfs/go-cid" + address "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-fil-markets/piecestore" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/venus/venus-shared/types" @@ -67,6 +68,40 @@ type DealInfoIncludePath struct { PublishCid cid.Cid } +type DealInfoV2 struct { + DealID abi.DealID + PublishCid cid.Cid + + AllocationID types.AllocationId + + PieceCID cid.Cid + PieceSize abi.PaddedPieceSize + Client address.Address + Provider address.Address + Offset abi.PaddedPieceSize + Length abi.PaddedPieceSize + PayloadSize uint64 + StartEpoch abi.ChainEpoch + EndEpoch abi.ChainEpoch +} + +func (d *DealInfoV2) IsBuiltinMarket() bool { + return d.PublishCid.Defined() +} + +type DirectDealInfo struct { + AllocationID types.AllocationId + PieceCID cid.Cid + PieceSize abi.PaddedPieceSize + Client address.Address + Provider address.Address + Offset abi.PaddedPieceSize + Length abi.PaddedPieceSize + PayloadSize uint64 + StartEpoch abi.ChainEpoch + EndEpoch abi.ChainEpoch +} + type PieceInfo struct { PieceCID cid.Cid Deals []*DealInfo diff --git a/venus-shared/types/market/storage.go b/venus-shared/types/market/storage.go index 673437483e..4b652c7cdc 100644 --- a/venus-shared/types/market/storage.go +++ b/venus-shared/types/market/storage.go @@ -148,3 +148,93 @@ type ImportDataResult struct { // deal import failed Message string } + +type DirectDealState int + +const ( + DealAllocation DirectDealState = iota + 1 + DealSealing + DealActive + DealExpired + DealSlashed + DealError + // DealWaitForData +) + +func (d DirectDealState) String() string { + switch d { + case DealAllocation: + return "DealAllocation" + // case DealWaitForData: + // return "DealWaitForData" + case DealSealing: + return "DealSealing" + case DealActive: + return "DealActive" + case DealExpired: + return "DealExpired" + case DealSlashed: + return "DealSlashed" + case DealError: + return "DealError" + } + + return "" +} + +type DirectDeal struct { + ID uuid.UUID + PieceCID cid.Cid + PieceSize abi.PaddedPieceSize + Client address.Address + Provider address.Address + + PayloadSize uint64 + + State DirectDealState + + AllocationID uint64 + ClaimID uint64 + + SectorID abi.SectorNumber + Offset abi.PaddedPieceSize + Length abi.PaddedPieceSize + + StartEpoch abi.ChainEpoch + EndEpoch abi.ChainEpoch + + Message string + + TimeStamp +} + +type DirectDealParams struct { + // Commp will not be calculated and verified + SkipCommP bool + // not copy car file to piece storage + NoCopyCarFile bool + // skip generate index + SkipGenerateIndex bool + + DealParams []DirectDealParam +} + +type DirectDealParam struct { + // FilePath and PayloadSize cannot both be empty + FilePath string + PayloadSize uint64 + + DealUUID uuid.UUID + AllocationID uint64 + PieceCID cid.Cid + Client address.Address +} + +type DirectDealQueryParams struct { + Provider address.Address + Client address.Address + State *DirectDealState + + Page + Asc bool +}