deals: move PaymentInfo to paych actor

This commit is contained in:
Łukasz Magiera 2019-08-07 22:16:26 +02:00 committed by whyrusleeping
parent 2114e8f555
commit a664098867
5 changed files with 19 additions and 14 deletions

View File

@ -3,11 +3,12 @@ package actors
import (
"bytes"
"github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/filecoin-project/go-lotus/chain/actors/aerrors"
"github.com/filecoin-project/go-lotus/chain/address"
"github.com/filecoin-project/go-lotus/chain/types"
cbor "github.com/ipfs/go-ipld-cbor"
)
const ChannelClosingDelay = 6 * 60 * 2 // six hours
@ -19,10 +20,19 @@ func init() {
cbor.RegisterCborType(Merge{})
cbor.RegisterCborType(LaneState{})
cbor.RegisterCborType(UpdateChannelState{})
cbor.RegisterCborType(PaymentInfo{})
}
type PaymentChannelActor struct{}
type PaymentInfo struct {
PayChActor address.Address
Payer address.Address
ChannelMessage cid.Cid
Vouchers []SignedVoucher
}
type LaneState struct {
Closed bool
Redeemed types.BigInt

View File

@ -2,6 +2,7 @@ package deals
import (
"context"
"github.com/filecoin-project/go-lotus/chain/actors"
"math"
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
@ -198,7 +199,7 @@ func (c *Client) Start(ctx context.Context, data cid.Cid, totalPrice types.BigIn
Size: uint64(size),
TotalPrice: totalPrice,
Duration: blocksDuration,
Payment: PaymentInfo{
Payment: actors.PaymentInfo{
PayChActor: address.Address{},
Payer: address.Address{},
ChannelMessage: dummyCid,

View File

@ -86,6 +86,8 @@ func NewHandler(w *wallet.Wallet, ds dtypes.MetadataDS, sb *sectorbuilder.Sector
}
func (h *Handler) Run(ctx context.Context) {
// TODO: restore state
go func() {
defer log.Error("quitting deal handler loop")
defer close(h.stopped)

View File

@ -37,6 +37,8 @@ func (h *Handler) accept(ctx context.Context, deal MinerDeal) error {
return xerrors.Errorf("deal proposal with unsupported serialization: %s", deal.Proposal.SerializationMode)
}
// TODO: check payment
log.Info("fetching data for a deal")
err := h.sendSignedResponse(StorageDealResponse{
State: Accepted,

View File

@ -10,7 +10,6 @@ import (
)
func init() {
cbor.RegisterCborType(PaymentInfo{})
cbor.RegisterCborType(StorageDealProposal{})
cbor.RegisterCborType(SignedStorageDealProposal{})
@ -41,15 +40,6 @@ const (
Complete
)
// TODO: this should probably be in a separate package with other paych utils
type PaymentInfo struct {
PayChActor address.Address
Payer address.Address
ChannelMessage cid.Cid
Vouchers []actors.SignedVoucher
}
type StorageDealProposal struct {
PieceRef string
SerializationMode SerializationMode
@ -59,7 +49,7 @@ type StorageDealProposal struct {
TotalPrice types.BigInt
Duration uint64
Payment PaymentInfo
Payment actors.PaymentInfo
MinerAddress address.Address
ClientAddress address.Address