Revert "wip"

This reverts commit 859256dadbe42f44b7ac77a4b99b56393f52e127.
This commit is contained in:
Łukasz Magiera 2019-10-15 06:39:01 +02:00
parent fb80d75b07
commit 7d471a6ce3
7 changed files with 33 additions and 33 deletions

View File

@ -40,7 +40,7 @@ var log = logging.Logger("deals")
type ClientDeal struct {
ProposalCid cid.Cid
Proposal UnsignedStorageDealProposal
Proposal StorageDealProposal
State api.DealState
Miner peer.ID
@ -189,7 +189,7 @@ func (c *Client) VerifyParams(ctx context.Context, data cid.Cid) (*actors.PieceI
}
func (c *Client) Start(ctx context.Context, p ClientDealProposal, vd *actors.PieceInclVoucherData) (cid.Cid, error) {
proposal := UnsignedStorageDealProposal{
proposal := StorageDealProposal{
PieceRef: p.Data,
SerializationMode: SerializationUnixFs,
CommP: vd.CommP[:],
@ -197,8 +197,8 @@ func (c *Client) Start(ctx context.Context, p ClientDealProposal, vd *actors.Pie
TotalPrice: p.TotalPrice,
Duration: p.Duration,
Payment: p.Payment,
Provider: p.MinerAddress,
Client: p.ClientAddress,
MinerAddress: p.MinerAddress,
ClientAddress: p.ClientAddress,
}
s, err := c.h.NewStream(ctx, p.MinerID, ProtocolID)
@ -229,7 +229,7 @@ func (c *Client) Start(ctx context.Context, p ClientDealProposal, vd *actors.Pie
// TODO: start tracking after the deal is sealed
return deal.ProposalCid, c.discovery.AddPeer(p.Data, discovery.RetrievalPeer{
Address: proposal.Provider,
Address: proposal.MinerAddress,
ID: deal.Miner,
})
}

View File

@ -64,7 +64,7 @@ func (c *Client) commP(ctx context.Context, data cid.Cid) ([]byte, int64, error)
return commP[:], size, err
}
func (c *Client) sendProposal(s inet.Stream, proposal UnsignedStorageDealProposal, from address.Address) error {
func (c *Client) sendProposal(s inet.Stream, proposal StorageDealProposal, from address.Address) error {
log.Info("Sending deal proposal")
msg, err := cbor.DumpObject(proposal)
@ -76,7 +76,7 @@ func (c *Client) sendProposal(s inet.Stream, proposal UnsignedStorageDealProposa
return err
}
signedProposal := &StorageDealProposal{
signedProposal := &SignedStorageDealProposal{
Proposal: proposal,
Signature: sig,
}

View File

@ -27,7 +27,7 @@ func init() {
type MinerDeal struct {
Client peer.ID
Proposal UnsignedStorageDealProposal
Proposal StorageDealProposal
ProposalCid cid.Cid
State api.DealState
@ -194,7 +194,7 @@ func (h *Handler) onUpdated(ctx context.Context, update minerDealUpdate) {
}
}
func (h *Handler) newDeal(s inet.Stream, proposal UnsignedStorageDealProposal) (MinerDeal, error) {
func (h *Handler) newDeal(s inet.Stream, proposal StorageDealProposal) (MinerDeal, error) {
// TODO: Review: Not signed?
proposalNd, err := cbor.WrapObject(proposal, math.MaxUint64, -1)
if err != nil {

View File

@ -52,8 +52,8 @@ func (h *Handler) checkVoucher(ctx context.Context, deal MinerDeal, voucher *typ
return xerrors.New("voucher.Extra not set")
}
if voucher.Extra.Actor != deal.Proposal.Provider {
return xerrors.Errorf("extra params actor didn't match miner address in proposal: '%s' != '%s'", voucher.Extra.Actor, deal.Proposal.Provider)
if voucher.Extra.Actor != deal.Proposal.MinerAddress {
return xerrors.Errorf("extra params actor didn't match miner address in proposal: '%s' != '%s'", voucher.Extra.Actor, deal.Proposal.MinerAddress)
}
if voucher.Extra.Method != actors.MAMethods.PaymentVerifyInclusion {
@ -294,7 +294,7 @@ func (h *Handler) sealing(ctx context.Context, deal MinerDeal) (func(*MinerDeal)
}
func (h *Handler) complete(ctx context.Context, deal MinerDeal) (func(*MinerDeal), error) {
mcid, err := h.commt.WaitCommit(ctx, deal.Proposal.Provider, deal.SectorID)
mcid, err := h.commt.WaitCommit(ctx, deal.Proposal.MinerAddress, deal.SectorID)
if err != nil {
log.Warnf("Waiting for sector commitment message: %s", err)
}

View File

@ -46,18 +46,18 @@ func (h *Handler) failDeal(id cid.Cid, cerr error) {
}
}
func (h *Handler) readProposal(s inet.Stream) (proposal StorageDealProposal, err error) {
func (h *Handler) readProposal(s inet.Stream) (proposal SignedStorageDealProposal, err error) {
if err := cborrpc.ReadCborRPC(s, &proposal); err != nil {
log.Errorw("failed to read proposal message", "error", err)
return StorageDealProposal{}, err
return SignedStorageDealProposal{}, err
}
// TODO: Validate proposal maybe
// (and signature, obviously)
if proposal.Proposal.Provider != h.actor {
log.Errorf("proposal with wrong Provider: %s", proposal.Proposal.Provider)
return StorageDealProposal{}, err
if proposal.Proposal.MinerAddress != h.actor {
log.Errorf("proposal with wrong MinerAddress: %s", proposal.Proposal.MinerAddress)
return SignedStorageDealProposal{}, err
}
return

View File

@ -5,13 +5,14 @@ import (
"github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/filecoin-project/go-lotus/chain/actors"
"github.com/filecoin-project/go-lotus/chain/address"
"github.com/filecoin-project/go-lotus/chain/types"
)
func init() {
cbor.RegisterCborType(UnsignedStorageDealProposal{})
cbor.RegisterCborType(StorageDealProposal{})
cbor.RegisterCborType(SignedStorageDealProposal{})
cbor.RegisterCborType(PieceInclusionProof{})
@ -33,26 +34,25 @@ const (
SerializationIPLD = "IPLD"
)
type UnsignedStorageDealProposal struct {
PieceRef cid.Cid // TODO: port to spec
PieceSize uint64
type StorageDealProposal struct {
PieceRef cid.Cid // TODO: port to spec
SerializationMode SerializationMode
CommP []byte
Client address.Address
Provider address.Address
Size uint64
TotalPrice types.BigInt
Duration uint64
ProposalExpiryEpoch uint64
DealExpiryEpoch uint64
Payment actors.PaymentInfo
StoragePrice types.BigInt
StorageCollateral types.BigInt
ProposerSignature *types.Signature
MinerAddress address.Address
ClientAddress address.Address
}
type StorageDealProposal struct {
UnsignedStorageDealProposal // TODO: check bytes
type SignedStorageDealProposal struct {
Proposal StorageDealProposal
ProposerSignature *types.Signature
Signature *types.Signature
}
// response

View File

@ -134,7 +134,7 @@ func (a *API) ClientListDeals(ctx context.Context) ([]api.DealInfo, error) {
out[k] = api.DealInfo{
ProposalCid: v.ProposalCid,
State: v.State,
Miner: v.Proposal.Provider,
Miner: v.Proposal.MinerAddress,
PieceRef: v.Proposal.PieceRef,
CommP: v.Proposal.CommP,