From 9ac22ae9b84c39cbef1262f9cd5daba7048fc1c3 Mon Sep 17 00:00:00 2001 From: 0x5459 <0x5459@protonmail.com> Date: Wed, 22 Mar 2023 17:30:47 +0800 Subject: [PATCH] feat: market: new api `ReleaseDeals` --- venus-shared/api/market/v1/api.go | 6 ++++-- venus-shared/api/market/v1/method.md | 19 +++++++++++++++++++ .../api/market/v1/mock/mock_imarket.go | 14 ++++++++++++++ venus-shared/api/market/v1/proxy_gen.go | 4 ++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/venus-shared/api/market/v1/api.go b/venus-shared/api/market/v1/api.go index 9c25f68abf..f8f36c63c3 100644 --- a/venus-shared/api/market/v1/api.go +++ b/venus-shared/api/market/v1/api.go @@ -157,8 +157,10 @@ type IMarket interface { UpdateDealStatus(ctx context.Context, miner address.Address, dealID abi.DealID, pieceStatus market.PieceStatus, dealStatus storagemarket.StorageDealStatus) error //perm:write GetDeals(ctx context.Context, miner address.Address, pageIndex, pageSize int) ([]*market.DealInfo, error) //perm:read AssignUnPackedDeals(ctx context.Context, sid abi.SectorID, ssize abi.SectorSize, spec *market.GetDealSpec) ([]*market.DealInfoIncludePath, 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 + // ReleaseDeals is used to release the deals that have been assigned by AssignUnPackedDeals method. + 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 // 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 diff --git a/venus-shared/api/market/v1/method.md b/venus-shared/api/market/v1/method.md index e90d2be39f..fa7829ec92 100644 --- a/venus-shared/api/market/v1/method.md +++ b/venus-shared/api/market/v1/method.md @@ -93,6 +93,7 @@ curl http://:/rpc/v1 -X POST -H "Content-Type: application/json" -H " * [PiecesGetPieceInfo](#piecesgetpieceinfo) * [PiecesListCidInfos](#pieceslistcidinfos) * [PiecesListPieces](#pieceslistpieces) + * [ReleaseDeals](#releasedeals) * [RemovePieceStorage](#removepiecestorage) * [ResponseMarketEvent](#responsemarketevent) * [SectorGetExpectedSealDuration](#sectorgetexpectedsealduration) @@ -2346,6 +2347,24 @@ Response: ] ``` +### ReleaseDeals +ReleaseDeals is used to release the deals that have been assigned by AssignUnPackedDeals method. + + +Perms: write + +Inputs: +```json +[ + "f01234", + [ + 5432 + ] +] +``` + +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 df2f3485e6..2e24bce8a6 100644 --- a/venus-shared/api/market/v1/mock/mock_imarket.go +++ b/venus-shared/api/market/v1/mock/mock_imarket.go @@ -1307,6 +1307,20 @@ func (mr *MockIMarketMockRecorder) PiecesListPieces(arg0 interface{}) *gomock.Ca return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PiecesListPieces", reflect.TypeOf((*MockIMarket)(nil).PiecesListPieces), arg0) } +// ReleaseDeals mocks base method. +func (m *MockIMarket) ReleaseDeals(arg0 context.Context, arg1 address.Address, arg2 []abi.DealID) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReleaseDeals", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// ReleaseDeals indicates an expected call of ReleaseDeals. +func (mr *MockIMarketMockRecorder) ReleaseDeals(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReleaseDeals", reflect.TypeOf((*MockIMarket)(nil).ReleaseDeals), 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 6439124bb2..dd1506a65a 100644 --- a/venus-shared/api/market/v1/proxy_gen.go +++ b/venus-shared/api/market/v1/proxy_gen.go @@ -108,6 +108,7 @@ type IMarketStruct struct { PiecesGetPieceInfo func(ctx context.Context, pieceCid cid.Cid) (*piecestore.PieceInfo, error) `perm:"read"` 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"` 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"` @@ -375,6 +376,9 @@ func (s *IMarketStruct) PiecesListCidInfos(p0 context.Context) ([]cid.Cid, error func (s *IMarketStruct) PiecesListPieces(p0 context.Context) ([]cid.Cid, error) { return s.Internal.PiecesListPieces(p0) } +func (s *IMarketStruct) ReleaseDeals(p0 context.Context, p1 address.Address, p2 []abi.DealID) error { + return s.Internal.ReleaseDeals(p0, p1, p2) +} func (s *IMarketStruct) RemovePieceStorage(p0 context.Context, p1 string) error { return s.Internal.RemovePieceStorage(p0, p1) }