From 12e011e709ac4169a1bc65d8758c3d9310d65517 Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Thu, 19 Oct 2023 15:15:57 +0800 Subject: [PATCH] feat: import data by uuid --- venus-shared/api/market/v0/api.go | 2 +- venus-shared/api/market/v0/method.md | 12 +++++++----- venus-shared/api/market/v0/mock/mock_imarket.go | 8 ++++---- venus-shared/api/market/v0/proxy_gen.go | 6 +++--- venus-shared/api/market/v1/api.go | 2 +- venus-shared/api/market/v1/method.md | 12 +++++++----- venus-shared/api/market/v1/mock/mock_imarket.go | 8 ++++---- venus-shared/api/market/v1/proxy_gen.go | 6 +++--- venus-shared/types/market/storage.go | 4 +++- 9 files changed, 33 insertions(+), 27 deletions(-) diff --git a/venus-shared/api/market/v0/api.go b/venus-shared/api/market/v0/api.go index a3ccff4000..d41bdcf796 100644 --- a/venus-shared/api/market/v0/api.go +++ b/venus-shared/api/market/v0/api.go @@ -56,7 +56,7 @@ type IMarket interface { PiecesGetPieceInfo(ctx context.Context, pieceCid cid.Cid) (*piecestore.PieceInfo, error) //perm:read PiecesGetCIDInfo(ctx context.Context, payloadCid cid.Cid) (*piecestore.CIDInfo, error) //perm:read - DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string, skipCommP bool) error //perm:admin + DealsImportData(ctx context.Context, ref market.ImportDataRef, skipCommP bool) error //perm:admin DealsBatchImportData(ctx context.Context, refs market.ImportDataRefs) ([]*market.ImportDataResult, error) //perm:admin DealsImport(ctx context.Context, deals []market.MinerDeal) error //perm:admin diff --git a/venus-shared/api/market/v0/method.md b/venus-shared/api/market/v0/method.md index e4a305df65..76cd317e58 100644 --- a/venus-shared/api/market/v0/method.md +++ b/venus-shared/api/market/v0/method.md @@ -456,6 +456,7 @@ Inputs: "ProposalCID": { "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" }, + "UUID": "07070707-0707-0707-0707-070707070707", "File": "string value" } ], @@ -468,9 +469,7 @@ Response: ```json [ { - "ProposalCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, + "Target": "string value", "Message": "string value" } ] @@ -650,9 +649,12 @@ Inputs: ```json [ { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + "ProposalCID": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "UUID": "07070707-0707-0707-0707-070707070707", + "File": "string value" }, - "string value", true ] ``` diff --git a/venus-shared/api/market/v0/mock/mock_imarket.go b/venus-shared/api/market/v0/mock/mock_imarket.go index c2278a68bf..ccfd02c774 100644 --- a/venus-shared/api/market/v0/mock/mock_imarket.go +++ b/venus-shared/api/market/v0/mock/mock_imarket.go @@ -387,17 +387,17 @@ func (mr *MockIMarketMockRecorder) DealsImport(arg0, arg1 interface{}) *gomock.C } // DealsImportData mocks base method. -func (m *MockIMarket) DealsImportData(arg0 context.Context, arg1 cid.Cid, arg2 string, arg3 bool) error { +func (m *MockIMarket) DealsImportData(arg0 context.Context, arg1 market.ImportDataRef, arg2 bool) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DealsImportData", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "DealsImportData", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 } // DealsImportData indicates an expected call of DealsImportData. -func (mr *MockIMarketMockRecorder) DealsImportData(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +func (mr *MockIMarketMockRecorder) DealsImportData(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DealsImportData", reflect.TypeOf((*MockIMarket)(nil).DealsImportData), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DealsImportData", reflect.TypeOf((*MockIMarket)(nil).DealsImportData), arg0, arg1, arg2) } // DealsMaxProviderCollateralMultiplier mocks base method. diff --git a/venus-shared/api/market/v0/proxy_gen.go b/venus-shared/api/market/v0/proxy_gen.go index 9f9e97adc1..425dff58a8 100644 --- a/venus-shared/api/market/v0/proxy_gen.go +++ b/venus-shared/api/market/v0/proxy_gen.go @@ -45,7 +45,7 @@ type IMarketStruct struct { DealsConsiderUnverifiedStorageDeals func(context.Context, address.Address) (bool, error) `perm:"read"` DealsConsiderVerifiedStorageDeals func(context.Context, address.Address) (bool, error) `perm:"read"` DealsImport func(ctx context.Context, deals []market.MinerDeal) error `perm:"admin"` - DealsImportData func(ctx context.Context, dealPropCid cid.Cid, file string, skipCommP bool) error `perm:"admin"` + DealsImportData func(ctx context.Context, ref market.ImportDataRef, skipCommP bool) error `perm:"admin"` DealsMaxProviderCollateralMultiplier func(context.Context, address.Address) (uint64, error) `perm:"read"` DealsMaxPublishFee func(context.Context, address.Address) (types.FIL, error) `perm:"read"` DealsMaxStartDelay func(context.Context, address.Address) (time.Duration, error) `perm:"read"` @@ -190,8 +190,8 @@ func (s *IMarketStruct) DealsConsiderVerifiedStorageDeals(p0 context.Context, p1 func (s *IMarketStruct) DealsImport(p0 context.Context, p1 []market.MinerDeal) error { return s.Internal.DealsImport(p0, p1) } -func (s *IMarketStruct) DealsImportData(p0 context.Context, p1 cid.Cid, p2 string, p3 bool) error { - return s.Internal.DealsImportData(p0, p1, p2, p3) +func (s *IMarketStruct) DealsImportData(p0 context.Context, p1 market.ImportDataRef, p2 bool) error { + return s.Internal.DealsImportData(p0, p1, p2) } func (s *IMarketStruct) DealsMaxProviderCollateralMultiplier(p0 context.Context, p1 address.Address) (uint64, error) { return s.Internal.DealsMaxProviderCollateralMultiplier(p0, p1) diff --git a/venus-shared/api/market/v1/api.go b/venus-shared/api/market/v1/api.go index c3a00bc43d..7062a63cf9 100644 --- a/venus-shared/api/market/v1/api.go +++ b/venus-shared/api/market/v1/api.go @@ -56,7 +56,7 @@ type IMarket interface { PiecesGetPieceInfo(ctx context.Context, pieceCid cid.Cid) (*piecestore.PieceInfo, error) //perm:read PiecesGetCIDInfo(ctx context.Context, payloadCid cid.Cid) (*piecestore.CIDInfo, error) //perm:read - DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string, skipCommP bool) error //perm:admin + DealsImportData(ctx context.Context, ref market.ImportDataRef, skipCommP bool) error //perm:admin DealsBatchImportData(ctx context.Context, refs market.ImportDataRefs) ([]*market.ImportDataResult, error) //perm:admin DealsImport(ctx context.Context, deals []*market.MinerDeal) error //perm:admin diff --git a/venus-shared/api/market/v1/method.md b/venus-shared/api/market/v1/method.md index 268347248f..4f6e9aef24 100644 --- a/venus-shared/api/market/v1/method.md +++ b/venus-shared/api/market/v1/method.md @@ -457,6 +457,7 @@ Inputs: "ProposalCID": { "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" }, + "UUID": "07070707-0707-0707-0707-070707070707", "File": "string value" } ], @@ -469,9 +470,7 @@ Response: ```json [ { - "ProposalCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, + "Target": "string value", "Message": "string value" } ] @@ -651,9 +650,12 @@ Inputs: ```json [ { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + "ProposalCID": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "UUID": "07070707-0707-0707-0707-070707070707", + "File": "string value" }, - "string value", true ] ``` diff --git a/venus-shared/api/market/v1/mock/mock_imarket.go b/venus-shared/api/market/v1/mock/mock_imarket.go index e658711ad4..caad5fd3d5 100644 --- a/venus-shared/api/market/v1/mock/mock_imarket.go +++ b/venus-shared/api/market/v1/mock/mock_imarket.go @@ -387,17 +387,17 @@ func (mr *MockIMarketMockRecorder) DealsImport(arg0, arg1 interface{}) *gomock.C } // DealsImportData mocks base method. -func (m *MockIMarket) DealsImportData(arg0 context.Context, arg1 cid.Cid, arg2 string, arg3 bool) error { +func (m *MockIMarket) DealsImportData(arg0 context.Context, arg1 market.ImportDataRef, arg2 bool) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DealsImportData", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "DealsImportData", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 } // DealsImportData indicates an expected call of DealsImportData. -func (mr *MockIMarketMockRecorder) DealsImportData(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +func (mr *MockIMarketMockRecorder) DealsImportData(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DealsImportData", reflect.TypeOf((*MockIMarket)(nil).DealsImportData), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DealsImportData", reflect.TypeOf((*MockIMarket)(nil).DealsImportData), arg0, arg1, arg2) } // DealsMaxProviderCollateralMultiplier mocks base method. diff --git a/venus-shared/api/market/v1/proxy_gen.go b/venus-shared/api/market/v1/proxy_gen.go index a9ebf79b72..329d04ef68 100644 --- a/venus-shared/api/market/v1/proxy_gen.go +++ b/venus-shared/api/market/v1/proxy_gen.go @@ -45,7 +45,7 @@ type IMarketStruct struct { DealsConsiderUnverifiedStorageDeals func(context.Context, address.Address) (bool, error) `perm:"read"` DealsConsiderVerifiedStorageDeals func(context.Context, address.Address) (bool, error) `perm:"read"` DealsImport func(ctx context.Context, deals []*market.MinerDeal) error `perm:"admin"` - DealsImportData func(ctx context.Context, dealPropCid cid.Cid, file string, skipCommP bool) error `perm:"admin"` + DealsImportData func(ctx context.Context, ref market.ImportDataRef, skipCommP bool) error `perm:"admin"` DealsMaxProviderCollateralMultiplier func(context.Context, address.Address) (uint64, error) `perm:"read"` DealsMaxPublishFee func(context.Context, address.Address) (types.FIL, error) `perm:"read"` DealsMaxStartDelay func(context.Context, address.Address) (time.Duration, error) `perm:"read"` @@ -191,8 +191,8 @@ func (s *IMarketStruct) DealsConsiderVerifiedStorageDeals(p0 context.Context, p1 func (s *IMarketStruct) DealsImport(p0 context.Context, p1 []*market.MinerDeal) error { return s.Internal.DealsImport(p0, p1) } -func (s *IMarketStruct) DealsImportData(p0 context.Context, p1 cid.Cid, p2 string, p3 bool) error { - return s.Internal.DealsImportData(p0, p1, p2, p3) +func (s *IMarketStruct) DealsImportData(p0 context.Context, p1 market.ImportDataRef, p2 bool) error { + return s.Internal.DealsImportData(p0, p1, p2) } func (s *IMarketStruct) DealsMaxProviderCollateralMultiplier(p0 context.Context, p1 address.Address) (uint64, error) { return s.Internal.DealsMaxProviderCollateralMultiplier(p0, p1) diff --git a/venus-shared/types/market/storage.go b/venus-shared/types/market/storage.go index 248c77d242..673437483e 100644 --- a/venus-shared/types/market/storage.go +++ b/venus-shared/types/market/storage.go @@ -133,6 +133,7 @@ type StorageDealQueryParams struct { type ImportDataRef struct { ProposalCID cid.Cid + UUID uuid.UUID File string } @@ -142,7 +143,8 @@ type ImportDataRefs struct { } type ImportDataResult struct { - ProposalCID cid.Cid + // Target may deal proposal cid or deal uuid + Target string // deal import failed Message string }