diff --git a/itests/paych_api_test.go b/itests/paych_api_test.go index 074551a83..1a39fd606 100644 --- a/itests/paych_api_test.go +++ b/itests/paych_api_test.go @@ -66,7 +66,6 @@ func TestPaymentChannelsAPI(t *testing.T) { channelAmt := int64(7000) channelInfo, err := paymentCreator.PaychGet(ctx, createrAddr, receiverAddr, abi.NewTokenAmount(channelAmt), api.PaychGetOpts{ - Reserve: true, OffChain: false, }) require.NoError(t, err) diff --git a/node/impl/paych/paych.go b/node/impl/paych/paych.go index 28e50625e..d338c6032 100644 --- a/node/impl/paych/paych.go +++ b/node/impl/paych/paych.go @@ -23,7 +23,10 @@ type PaychAPI struct { } func (a *PaychAPI) PaychGet(ctx context.Context, from, to address.Address, amt types.BigInt, opts api.PaychGetOpts) (*api.ChannelInfo, error) { - ch, mcid, err := a.PaychMgr.GetPaych(ctx, from, to, amt, true, opts) + ch, mcid, err := a.PaychMgr.GetPaych(ctx, from, to, amt, paychmgr.GetOpts{ + Reserve: true, + OffChain: opts.OffChain, + }) if err != nil { return nil, err } @@ -35,7 +38,10 @@ func (a *PaychAPI) PaychGet(ctx context.Context, from, to address.Address, amt t } func (a *PaychAPI) PaychFund(ctx context.Context, from, to address.Address, amt types.BigInt) (*api.ChannelInfo, error) { - ch, mcid, err := a.PaychMgr.GetPaych(ctx, from, to, amt, false, api.PaychGetOpts{OffChain: false}) + ch, mcid, err := a.PaychMgr.GetPaych(ctx, from, to, amt, paychmgr.GetOpts{ + Reserve: false, + OffChain: false, + }) if err != nil { return nil, err } diff --git a/paychmgr/manager.go b/paychmgr/manager.go index 46466266d..081ef4c5d 100644 --- a/paychmgr/manager.go +++ b/paychmgr/manager.go @@ -101,17 +101,12 @@ func (pm *Manager) Stop() error { return nil } -type getOpts struct { +type GetOpts struct { Reserve bool OffChain bool } -func (pm *Manager) GetPaych(ctx context.Context, from, to address.Address, amt types.BigInt, reserve bool, o api.PaychGetOpts) (address.Address, cid.Cid, error) { - opts := getOpts{ - Reserve: reserve, - OffChain: o.OffChain, - } - +func (pm *Manager) GetPaych(ctx context.Context, from, to address.Address, amt types.BigInt, opts GetOpts) (address.Address, cid.Cid, error) { if !opts.Reserve && opts.OffChain { return address.Undef, cid.Undef, xerrors.Errorf("can't fund payment channels without on-chain operations") } diff --git a/paychmgr/paychget_test.go b/paychmgr/paychget_test.go index a508fdfc9..0688301e8 100644 --- a/paychmgr/paychget_test.go +++ b/paychmgr/paychget_test.go @@ -19,26 +19,25 @@ import ( init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init" tutils "github.com/filecoin-project/specs-actors/v2/support/testing" - "github.com/filecoin-project/lotus/api" lotusinit "github.com/filecoin-project/lotus/chain/actors/builtin/init" "github.com/filecoin-project/lotus/chain/actors/builtin/paych" paychmock "github.com/filecoin-project/lotus/chain/actors/builtin/paych/mock" "github.com/filecoin-project/lotus/chain/types" ) -var onChainReserve = api.PaychGetOpts{ +var onChainReserve = GetOpts{ Reserve: true, OffChain: false, } -var onChainNoReserve = api.PaychGetOpts{ +var onChainNoReserve = GetOpts{ Reserve: false, OffChain: false, } -var offChainReserve = api.PaychGetOpts{ +var offChainReserve = GetOpts{ Reserve: true, OffChain: true, } -var offChainNoReserve = api.PaychGetOpts{ +var offChainNoReserve = GetOpts{ Reserve: false, OffChain: true, } diff --git a/paychmgr/simple.go b/paychmgr/simple.go index cc6a92861..0eb1316af 100644 --- a/paychmgr/simple.go +++ b/paychmgr/simple.go @@ -33,14 +33,14 @@ type fundsReq struct { ctx context.Context promise chan *paychFundsRes amt types.BigInt - opts getOpts + opts GetOpts lk sync.Mutex // merge parent, if this req is part of a merge merge *mergedFundsReq } -func newFundsReq(ctx context.Context, amt types.BigInt, opts getOpts) *fundsReq { +func newFundsReq(ctx context.Context, amt types.BigInt, opts GetOpts) *fundsReq { promise := make(chan *paychFundsRes, 1) return &fundsReq{ ctx: ctx, @@ -251,7 +251,7 @@ func (m *mergedFundsReq) failOffChainNoChannel(from, to address.Address) (*paych // address and the CID of the new add funds message. // If an operation returns an error, subsequent waiting operations will still // be attempted. -func (ca *channelAccessor) getPaych(ctx context.Context, amt types.BigInt, opts getOpts) (address.Address, cid.Cid, error) { +func (ca *channelAccessor) getPaych(ctx context.Context, amt types.BigInt, opts GetOpts) (address.Address, cid.Cid, error) { // Add the request to add funds to a queue and wait for the result freq := newFundsReq(ctx, amt, opts) ca.enqueue(ctx, freq)