wip
This commit is contained in:
parent
16a9ab875c
commit
007bdfaf42
@ -40,7 +40,7 @@ var log = logging.Logger("deals")
|
|||||||
|
|
||||||
type ClientDeal struct {
|
type ClientDeal struct {
|
||||||
ProposalCid cid.Cid
|
ProposalCid cid.Cid
|
||||||
Proposal StorageDealProposal
|
Proposal UnsignedStorageDealProposal
|
||||||
State api.DealState
|
State api.DealState
|
||||||
Miner peer.ID
|
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) {
|
func (c *Client) Start(ctx context.Context, p ClientDealProposal, vd *actors.PieceInclVoucherData) (cid.Cid, error) {
|
||||||
proposal := StorageDealProposal{
|
proposal := UnsignedStorageDealProposal{
|
||||||
PieceRef: p.Data,
|
PieceRef: p.Data,
|
||||||
SerializationMode: SerializationUnixFs,
|
SerializationMode: SerializationUnixFs,
|
||||||
CommP: vd.CommP[:],
|
CommP: vd.CommP[:],
|
||||||
@ -197,8 +197,8 @@ func (c *Client) Start(ctx context.Context, p ClientDealProposal, vd *actors.Pie
|
|||||||
TotalPrice: p.TotalPrice,
|
TotalPrice: p.TotalPrice,
|
||||||
Duration: p.Duration,
|
Duration: p.Duration,
|
||||||
Payment: p.Payment,
|
Payment: p.Payment,
|
||||||
MinerAddress: p.MinerAddress,
|
Provider: p.MinerAddress,
|
||||||
ClientAddress: p.ClientAddress,
|
Client: p.ClientAddress,
|
||||||
}
|
}
|
||||||
|
|
||||||
s, err := c.h.NewStream(ctx, p.MinerID, ProtocolID)
|
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
|
// TODO: start tracking after the deal is sealed
|
||||||
return deal.ProposalCid, c.discovery.AddPeer(p.Data, discovery.RetrievalPeer{
|
return deal.ProposalCid, c.discovery.AddPeer(p.Data, discovery.RetrievalPeer{
|
||||||
Address: proposal.MinerAddress,
|
Address: proposal.Provider,
|
||||||
ID: deal.Miner,
|
ID: deal.Miner,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ func (c *Client) commP(ctx context.Context, data cid.Cid) ([]byte, int64, error)
|
|||||||
return commP[:], size, err
|
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")
|
log.Info("Sending deal proposal")
|
||||||
|
|
||||||
msg, err := cbor.DumpObject(proposal)
|
msg, err := cbor.DumpObject(proposal)
|
||||||
@ -76,7 +76,7 @@ func (c *Client) sendProposal(s inet.Stream, proposal StorageDealProposal, from
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
signedProposal := &SignedStorageDealProposal{
|
signedProposal := &StorageDealProposal{
|
||||||
Proposal: proposal,
|
Proposal: proposal,
|
||||||
Signature: sig,
|
Signature: sig,
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ func init() {
|
|||||||
|
|
||||||
type MinerDeal struct {
|
type MinerDeal struct {
|
||||||
Client peer.ID
|
Client peer.ID
|
||||||
Proposal StorageDealProposal
|
Proposal UnsignedStorageDealProposal
|
||||||
ProposalCid cid.Cid
|
ProposalCid cid.Cid
|
||||||
State api.DealState
|
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?
|
// TODO: Review: Not signed?
|
||||||
proposalNd, err := cbor.WrapObject(proposal, math.MaxUint64, -1)
|
proposalNd, err := cbor.WrapObject(proposal, math.MaxUint64, -1)
|
||||||
if err != nil {
|
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")
|
return xerrors.New("voucher.Extra not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
if 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.MinerAddress)
|
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 {
|
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) {
|
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 {
|
if err != nil {
|
||||||
log.Warnf("Waiting for sector commitment message: %s", err)
|
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 {
|
if err := cborrpc.ReadCborRPC(s, &proposal); err != nil {
|
||||||
log.Errorw("failed to read proposal message", "error", err)
|
log.Errorw("failed to read proposal message", "error", err)
|
||||||
return SignedStorageDealProposal{}, err
|
return StorageDealProposal{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Validate proposal maybe
|
// TODO: Validate proposal maybe
|
||||||
// (and signature, obviously)
|
// (and signature, obviously)
|
||||||
|
|
||||||
if proposal.Proposal.MinerAddress != h.actor {
|
if proposal.Proposal.Provider != h.actor {
|
||||||
log.Errorf("proposal with wrong MinerAddress: %s", proposal.Proposal.MinerAddress)
|
log.Errorf("proposal with wrong Provider: %s", proposal.Proposal.Provider)
|
||||||
return SignedStorageDealProposal{}, err
|
return StorageDealProposal{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -5,14 +5,13 @@ import (
|
|||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
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/address"
|
||||||
"github.com/filecoin-project/go-lotus/chain/types"
|
"github.com/filecoin-project/go-lotus/chain/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
cbor.RegisterCborType(UnsignedStorageDealProposal{})
|
||||||
cbor.RegisterCborType(StorageDealProposal{})
|
cbor.RegisterCborType(StorageDealProposal{})
|
||||||
cbor.RegisterCborType(SignedStorageDealProposal{})
|
|
||||||
|
|
||||||
cbor.RegisterCborType(PieceInclusionProof{})
|
cbor.RegisterCborType(PieceInclusionProof{})
|
||||||
|
|
||||||
@ -34,25 +33,26 @@ const (
|
|||||||
SerializationIPLD = "IPLD"
|
SerializationIPLD = "IPLD"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StorageDealProposal struct {
|
type UnsignedStorageDealProposal struct {
|
||||||
PieceRef cid.Cid // TODO: port to spec
|
PieceRef cid.Cid // TODO: port to spec
|
||||||
SerializationMode SerializationMode
|
PieceSize uint64
|
||||||
CommP []byte
|
|
||||||
|
|
||||||
Size uint64
|
Client address.Address
|
||||||
TotalPrice types.BigInt
|
Provider address.Address
|
||||||
Duration uint64
|
|
||||||
|
|
||||||
Payment actors.PaymentInfo
|
ProposalExpiryEpoch uint64
|
||||||
|
DealExpiryEpoch uint64
|
||||||
|
|
||||||
MinerAddress address.Address
|
StoragePrice types.BigInt
|
||||||
ClientAddress address.Address
|
StorageCollateral types.BigInt
|
||||||
|
|
||||||
|
ProposerSignature *types.Signature
|
||||||
}
|
}
|
||||||
|
|
||||||
type SignedStorageDealProposal struct {
|
type StorageDealProposal struct {
|
||||||
Proposal StorageDealProposal
|
UnsignedStorageDealProposal // TODO: check bytes
|
||||||
|
|
||||||
Signature *types.Signature
|
ProposerSignature *types.Signature
|
||||||
}
|
}
|
||||||
|
|
||||||
// response
|
// response
|
||||||
|
@ -134,7 +134,7 @@ func (a *API) ClientListDeals(ctx context.Context) ([]api.DealInfo, error) {
|
|||||||
out[k] = api.DealInfo{
|
out[k] = api.DealInfo{
|
||||||
ProposalCid: v.ProposalCid,
|
ProposalCid: v.ProposalCid,
|
||||||
State: v.State,
|
State: v.State,
|
||||||
Miner: v.Proposal.MinerAddress,
|
Miner: v.Proposal.Provider,
|
||||||
|
|
||||||
PieceRef: v.Proposal.PieceRef,
|
PieceRef: v.Proposal.PieceRef,
|
||||||
CommP: v.Proposal.CommP,
|
CommP: v.Proposal.CommP,
|
||||||
|
Loading…
Reference in New Issue
Block a user