diff --git a/node/impl/paych/paych.go b/node/impl/paych/paych.go index 8e28979f5..e7f39e400 100644 --- a/node/impl/paych/paych.go +++ b/node/impl/paych/paych.go @@ -116,25 +116,7 @@ func (a *PaychAPI) PaychSettle(ctx context.Context, addr address.Address) (cid.C } func (a *PaychAPI) PaychCollect(ctx context.Context, addr address.Address) (cid.Cid, error) { - - ci, err := a.PaychMgr.GetChannelInfo(addr) - if err != nil { - return cid.Undef, err - } - - msg := &types.Message{ - To: addr, - From: ci.Control, - Value: types.NewInt(0), - Method: builtin.MethodsPaych.Collect, - } - - smsg, err := a.MpoolPushMessage(ctx, msg) - if err != nil { - return cid.Undef, err - } - - return smsg.Cid(), nil + return a.PaychMgr.Collect(ctx, addr) } func (a *PaychAPI) PaychVoucherCheckValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) error { diff --git a/paychmgr/manager.go b/paychmgr/manager.go index 7f47640f1..a75c79515 100644 --- a/paychmgr/manager.go +++ b/paychmgr/manager.go @@ -242,3 +242,11 @@ func (pm *Manager) Settle(ctx context.Context, addr address.Address) (cid.Cid, e } return ca.settle(ctx, addr) } + +func (pm *Manager) Collect(ctx context.Context, addr address.Address) (cid.Cid, error) { + ca, err := pm.accessorByAddress(addr) + if err != nil { + return cid.Undef, err + } + return ca.collect(ctx, addr) +} diff --git a/paychmgr/paych.go b/paychmgr/paych.go index f1d5199f6..ba2018e96 100644 --- a/paychmgr/paych.go +++ b/paychmgr/paych.go @@ -417,3 +417,27 @@ func (ca *channelAccessor) settle(ctx context.Context, ch address.Address) (cid. return smgs.Cid(), err } + +func (ca *channelAccessor) collect(ctx context.Context, ch address.Address) (cid.Cid, error) { + ca.lk.Lock() + defer ca.lk.Unlock() + + ci, err := ca.store.ByAddress(ch) + if err != nil { + return cid.Undef, err + } + + msg := &types.Message{ + To: ch, + From: ci.Control, + Value: types.NewInt(0), + Method: builtin.MethodsPaych.Collect, + } + + smsg, err := ca.api.MpoolPushMessage(ctx, msg) + if err != nil { + return cid.Undef, err + } + + return smsg.Cid(), nil +}