API shouldn't depend on actors directly

This commit is contained in:
Aayush Rajasekaran
2020-09-23 00:51:12 -04:00
parent 773714792f
commit ed4bf9b8fe
5 changed files with 22 additions and 16 deletions
+10 -11
View File
@@ -10,9 +10,8 @@ import (
"github.com/filecoin-project/go-address"
paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
"github.com/filecoin-project/lotus/chain/types"
full "github.com/filecoin-project/lotus/node/impl/full"
"github.com/filecoin-project/lotus/paychmgr"
@@ -71,10 +70,10 @@ func (a *PaychAPI) PaychNewPayment(ctx context.Context, from, to address.Address
return nil, err
}
svs := make([]*paych0.SignedVoucher, len(vouchers))
svs := make([]*paych.SignedVoucher, len(vouchers))
for i, v := range vouchers {
sv, err := a.PaychMgr.CreateVoucher(ctx, ch.Channel, paych0.SignedVoucher{
sv, err := a.PaychMgr.CreateVoucher(ctx, ch.Channel, paych.SignedVoucher{
Amount: v.Amount,
Lane: lane,
@@ -123,15 +122,15 @@ func (a *PaychAPI) PaychCollect(ctx context.Context, addr address.Address) (cid.
return a.PaychMgr.Collect(ctx, addr)
}
func (a *PaychAPI) PaychVoucherCheckValid(ctx context.Context, ch address.Address, sv *paych0.SignedVoucher) error {
func (a *PaychAPI) PaychVoucherCheckValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) error {
return a.PaychMgr.CheckVoucherValid(ctx, ch, sv)
}
func (a *PaychAPI) PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, sv *paych0.SignedVoucher, secret []byte, proof []byte) (bool, error) {
func (a *PaychAPI) PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (bool, error) {
return a.PaychMgr.CheckVoucherSpendable(ctx, ch, sv, secret, proof)
}
func (a *PaychAPI) PaychVoucherAdd(ctx context.Context, ch address.Address, sv *paych0.SignedVoucher, proof []byte, minDelta types.BigInt) (types.BigInt, error) {
func (a *PaychAPI) PaychVoucherAdd(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta types.BigInt) (types.BigInt, error) {
return a.PaychMgr.AddVoucherInbound(ctx, ch, sv, proof, minDelta)
}
@@ -143,16 +142,16 @@ func (a *PaychAPI) PaychVoucherAdd(ctx context.Context, ch address.Address, sv *
// If there are insufficient funds in the channel to create the voucher,
// returns a nil voucher and the shortfall.
func (a *PaychAPI) PaychVoucherCreate(ctx context.Context, pch address.Address, amt types.BigInt, lane uint64) (*api.VoucherCreateResult, error) {
return a.PaychMgr.CreateVoucher(ctx, pch, paych0.SignedVoucher{Amount: amt, Lane: lane})
return a.PaychMgr.CreateVoucher(ctx, pch, paych.SignedVoucher{Amount: amt, Lane: lane})
}
func (a *PaychAPI) PaychVoucherList(ctx context.Context, pch address.Address) ([]*paych0.SignedVoucher, error) {
func (a *PaychAPI) PaychVoucherList(ctx context.Context, pch address.Address) ([]*paych.SignedVoucher, error) {
vi, err := a.PaychMgr.ListVouchers(ctx, pch)
if err != nil {
return nil, err
}
out := make([]*paych0.SignedVoucher, len(vi))
out := make([]*paych.SignedVoucher, len(vi))
for k, v := range vi {
out[k] = v.Voucher
}
@@ -160,6 +159,6 @@ func (a *PaychAPI) PaychVoucherList(ctx context.Context, pch address.Address) ([
return out, nil
}
func (a *PaychAPI) PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *paych0.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) {
func (a *PaychAPI) PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) {
return a.PaychMgr.SubmitVoucher(ctx, ch, sv, secret, proof)
}