wip
This commit is contained in:
parent
16a9ab875c
commit
007bdfaf42
@ -40,7 +40,7 @@ var log = logging.Logger("deals")
|
||||
|
||||
type ClientDeal struct {
|
||||
ProposalCid cid.Cid
|
||||
Proposal StorageDealProposal
|
||||
Proposal UnsignedStorageDealProposal
|
||||
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 := StorageDealProposal{
|
||||
proposal := UnsignedStorageDealProposal{
|
||||
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,
|
||||
MinerAddress: p.MinerAddress,
|
||||
ClientAddress: p.ClientAddress,
|
||||
Provider: p.MinerAddress,
|
||||
Client: 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.MinerAddress,
|
||||
Address: proposal.Provider,
|
||||
ID: deal.Miner,
|
||||
})
|
||||
}
|
||||
|
@ -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 StorageDealProposal, from address.Address) error {
|
||||
func (c *Client) sendProposal(s inet.Stream, proposal UnsignedStorageDealProposal, 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 StorageDealProposal, from
|
||||
return err
|
||||
}
|
||||
|
||||
signedProposal := &SignedStorageDealProposal{
|
||||
signedProposal := &StorageDealProposal{
|
||||
Proposal: proposal,
|
||||
Signature: sig,
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ func init() {
|
||||
|
||||
type MinerDeal struct {
|
||||
Client peer.ID
|
||||
Proposal StorageDealProposal
|
||||
Proposal UnsignedStorageDealProposal
|
||||
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 StorageDealProposal) (MinerDeal, error) {
|
||||
func (h *Handler) newDeal(s inet.Stream, proposal UnsignedStorageDealProposal) (MinerDeal, error) {
|
||||
// TODO: Review: Not signed?
|
||||
proposalNd, err := cbor.WrapObject(proposal, math.MaxUint64, -1)
|
||||
if err != nil {
|
||||
|
@ -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.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.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.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.MinerAddress, deal.SectorID)
|
||||
mcid, err := h.commt.WaitCommit(ctx, deal.Proposal.Provider, deal.SectorID)
|
||||
if err != nil {
|
||||
log.Warnf("Waiting for sector commitment message: %s", err)
|
||||
}
|
||||
|
@ -46,18 +46,18 @@ func (h *Handler) failDeal(id cid.Cid, cerr error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handler) readProposal(s inet.Stream) (proposal SignedStorageDealProposal, err error) {
|
||||
func (h *Handler) readProposal(s inet.Stream) (proposal StorageDealProposal, err error) {
|
||||
if err := cborrpc.ReadCborRPC(s, &proposal); err != nil {
|
||||
log.Errorw("failed to read proposal message", "error", err)
|
||||
return SignedStorageDealProposal{}, err
|
||||
return StorageDealProposal{}, err
|
||||
}
|
||||
|
||||
// TODO: Validate proposal maybe
|
||||
// (and signature, obviously)
|
||||
|
||||
if proposal.Proposal.MinerAddress != h.actor {
|
||||
log.Errorf("proposal with wrong MinerAddress: %s", proposal.Proposal.MinerAddress)
|
||||
return SignedStorageDealProposal{}, err
|
||||
if proposal.Proposal.Provider != h.actor {
|
||||
log.Errorf("proposal with wrong Provider: %s", proposal.Proposal.Provider)
|
||||
return StorageDealProposal{}, err
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -1,18 +1,17 @@
|
||||
package deals
|
||||
package deals
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-lotus/api"
|
||||
"github.com/ipfs/go-cid"
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
import (
|
||||
"github.com/filecoin-project/go-lotus/api"
|
||||
"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"
|
||||
)
|
||||
"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{})
|
||||
|
||||
@ -34,25 +33,26 @@ const (
|
||||
SerializationIPLD = "IPLD"
|
||||
)
|
||||
|
||||
type StorageDealProposal struct {
|
||||
type UnsignedStorageDealProposal struct {
|
||||
PieceRef cid.Cid // TODO: port to spec
|
||||
SerializationMode SerializationMode
|
||||
CommP []byte
|
||||
PieceSize uint64
|
||||
|
||||
Size uint64
|
||||
TotalPrice types.BigInt
|
||||
Duration uint64
|
||||
Client address.Address
|
||||
Provider address.Address
|
||||
|
||||
Payment actors.PaymentInfo
|
||||
ProposalExpiryEpoch uint64
|
||||
DealExpiryEpoch uint64
|
||||
|
||||
MinerAddress address.Address
|
||||
ClientAddress address.Address
|
||||
StoragePrice types.BigInt
|
||||
StorageCollateral types.BigInt
|
||||
|
||||
ProposerSignature *types.Signature
|
||||
}
|
||||
|
||||
type SignedStorageDealProposal struct {
|
||||
Proposal StorageDealProposal
|
||||
type StorageDealProposal struct {
|
||||
UnsignedStorageDealProposal // TODO: check bytes
|
||||
|
||||
Signature *types.Signature
|
||||
ProposerSignature *types.Signature
|
||||
}
|
||||
|
||||
// response
|
||||
|
@ -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.MinerAddress,
|
||||
Miner: v.Proposal.Provider,
|
||||
|
||||
PieceRef: v.Proposal.PieceRef,
|
||||
CommP: v.Proposal.CommP,
|
||||
|
Loading…
Reference in New Issue
Block a user