Merge pull request #5871 from filecoin-project/nonsense/add-cancel-retrieval-deal-cmd
add `lotus client cancel-retrieval` cmd to lotus CLI
This commit is contained in:
commit
9adb30c560
@ -340,6 +340,9 @@ type FullNode interface {
|
||||
// which are stuck due to insufficient funds
|
||||
ClientRetrieveTryRestartInsufficientFunds(ctx context.Context, paymentChannel address.Address) error //perm:write
|
||||
|
||||
// ClientCancelRetrievalDeal cancels an ongoing retrieval deal based on DealID
|
||||
ClientCancelRetrievalDeal(ctx context.Context, dealid retrievalmarket.DealID) error //perm:write
|
||||
|
||||
// ClientUnimport removes references to the specified file from filestore
|
||||
//ClientUnimport(path string)
|
||||
|
||||
|
@ -155,6 +155,8 @@ type FullNodeStruct struct {
|
||||
|
||||
ClientCancelDataTransfer func(p0 context.Context, p1 datatransfer.TransferID, p2 peer.ID, p3 bool) error `perm:"write"`
|
||||
|
||||
ClientCancelRetrievalDeal func(p0 context.Context, p1 retrievalmarket.DealID) error `perm:"write"`
|
||||
|
||||
ClientDataTransferUpdates func(p0 context.Context) (<-chan api.DataTransferChannel, error) `perm:"write"`
|
||||
|
||||
ClientDealPieceCID func(p0 context.Context, p1 cid.Cid) (api.DataCIDSize, error) `perm:"read"`
|
||||
@ -981,6 +983,10 @@ func (s *FullNodeStruct) ClientCancelDataTransfer(p0 context.Context, p1 datatra
|
||||
return s.Internal.ClientCancelDataTransfer(p0, p1, p2, p3)
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) ClientCancelRetrievalDeal(p0 context.Context, p1 retrievalmarket.DealID) error {
|
||||
return s.Internal.ClientCancelRetrievalDeal(p0, p1)
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) ClientDataTransferUpdates(p0 context.Context) (<-chan api.DataTransferChannel, error) {
|
||||
return s.Internal.ClientDataTransferUpdates(p0)
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
address "github.com/filecoin-project/go-address"
|
||||
bitfield "github.com/filecoin-project/go-bitfield"
|
||||
datatransfer "github.com/filecoin-project/go-data-transfer"
|
||||
retrievalmarket "github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
||||
storagemarket "github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||
auth "github.com/filecoin-project/go-jsonrpc/auth"
|
||||
multistore "github.com/filecoin-project/go-multistore"
|
||||
@ -445,6 +446,20 @@ func (mr *MockFullNodeMockRecorder) ClientCancelDataTransfer(arg0, arg1, arg2, a
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClientCancelDataTransfer", reflect.TypeOf((*MockFullNode)(nil).ClientCancelDataTransfer), arg0, arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
// ClientCancelRetrievalDeal mocks base method
|
||||
func (m *MockFullNode) ClientCancelRetrievalDeal(arg0 context.Context, arg1 retrievalmarket.DealID) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ClientCancelRetrievalDeal", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ClientCancelRetrievalDeal indicates an expected call of ClientCancelRetrievalDeal
|
||||
func (mr *MockFullNodeMockRecorder) ClientCancelRetrievalDeal(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClientCancelRetrievalDeal", reflect.TypeOf((*MockFullNode)(nil).ClientCancelRetrievalDeal), arg0, arg1)
|
||||
}
|
||||
|
||||
// ClientDataTransferUpdates mocks base method
|
||||
func (m *MockFullNode) ClientDataTransferUpdates(arg0 context.Context) (<-chan api.DataTransferChannel, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -89,6 +89,7 @@ var clientCmd = &cli.Command{
|
||||
WithCategory("data", clientStat),
|
||||
WithCategory("retrieval", clientFindCmd),
|
||||
WithCategory("retrieval", clientRetrieveCmd),
|
||||
WithCategory("retrieval", clientCancelRetrievalDealCmd),
|
||||
WithCategory("util", clientCommPCmd),
|
||||
WithCategory("util", clientCarGenCmd),
|
||||
WithCategory("util", clientBalancesCmd),
|
||||
@ -2029,6 +2030,33 @@ var clientCancelTransfer = &cli.Command{
|
||||
},
|
||||
}
|
||||
|
||||
var clientCancelRetrievalDealCmd = &cli.Command{
|
||||
Name: "cancel-retrieval",
|
||||
Usage: "Cancel a retrieval deal by deal ID; this also cancels the associated transfer",
|
||||
Flags: []cli.Flag{
|
||||
&cli.Int64Flag{
|
||||
Name: "deal-id",
|
||||
Usage: "specify retrieval deal by deal ID",
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, closer, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer closer()
|
||||
ctx := ReqContext(cctx)
|
||||
|
||||
id := cctx.Int64("deal-id")
|
||||
if id < 0 {
|
||||
return errors.New("deal id cannot be negative")
|
||||
}
|
||||
|
||||
return api.ClientCancelRetrievalDeal(ctx, retrievalmarket.DealID(id))
|
||||
},
|
||||
}
|
||||
|
||||
var clientListTransfers = &cli.Command{
|
||||
Name: "list-transfers",
|
||||
Usage: "List ongoing data transfers for deals",
|
||||
|
@ -35,6 +35,7 @@
|
||||
* [Client](#Client)
|
||||
* [ClientCalcCommP](#ClientCalcCommP)
|
||||
* [ClientCancelDataTransfer](#ClientCancelDataTransfer)
|
||||
* [ClientCancelRetrievalDeal](#ClientCancelRetrievalDeal)
|
||||
* [ClientDataTransferUpdates](#ClientDataTransferUpdates)
|
||||
* [ClientDealPieceCID](#ClientDealPieceCID)
|
||||
* [ClientDealSize](#ClientDealSize)
|
||||
@ -921,6 +922,21 @@ Inputs:
|
||||
|
||||
Response: `{}`
|
||||
|
||||
### ClientCancelRetrievalDeal
|
||||
ClientCancelRetrievalDeal cancels an ongoing retrieval deal based on DealID
|
||||
|
||||
|
||||
Perms: write
|
||||
|
||||
Inputs:
|
||||
```json
|
||||
[
|
||||
5
|
||||
]
|
||||
```
|
||||
|
||||
Response: `{}`
|
||||
|
||||
### ClientDataTransferUpdates
|
||||
|
||||
|
||||
|
@ -475,6 +475,29 @@ func (a *API) ClientListImports(ctx context.Context) ([]api.Import, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (a *API) ClientCancelRetrievalDeal(ctx context.Context, dealID retrievalmarket.DealID) error {
|
||||
cerr := make(chan error)
|
||||
go func() {
|
||||
err := a.Retrieval.CancelDeal(dealID)
|
||||
|
||||
select {
|
||||
case cerr <- err:
|
||||
case <-ctx.Done():
|
||||
}
|
||||
}()
|
||||
|
||||
select {
|
||||
case err := <-cerr:
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to cancel retrieval deal: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
case <-ctx.Done():
|
||||
return xerrors.Errorf("context timeout while canceling retrieval deal: %w", ctx.Err())
|
||||
}
|
||||
}
|
||||
|
||||
func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, ref *api.FileRef) error {
|
||||
events := make(chan marketevents.RetrievalEvent)
|
||||
go a.clientRetrieve(ctx, order, ref, events)
|
||||
|
Loading…
Reference in New Issue
Block a user