Fix client market impl, gofmt
This commit is contained in:
parent
91b2d2c2fe
commit
e5ab64a3ab
@ -110,7 +110,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
||||
for pi, preseal := range m.Sectors {
|
||||
// Precommit
|
||||
{
|
||||
params := &miner.PreCommitSectorParams{Info:miner.SectorPreCommitInfo{
|
||||
params := &miner.PreCommitSectorParams{Info: miner.SectorPreCommitInfo{
|
||||
SectorNumber: preseal.SectorID,
|
||||
SealedCID: commcid.ReplicaCommitmentV1ToCID(preseal.CommR[:]),
|
||||
SealEpoch: 0,
|
||||
|
@ -183,8 +183,7 @@ func (st *StateTree) RegisterNewAddress(addr address.Address, act *types.Actor)
|
||||
return out, nil
|
||||
}
|
||||
|
||||
|
||||
type adtStore struct {cbor.IpldStore}
|
||||
type adtStore struct{ cbor.IpldStore }
|
||||
|
||||
func (a *adtStore) Context() context.Context {
|
||||
return context.TODO()
|
||||
|
@ -2,6 +2,7 @@ package types
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
)
|
||||
|
||||
@ -10,10 +11,7 @@ func init() {
|
||||
cbor.RegisterCborType(StorageAsk{})
|
||||
}
|
||||
|
||||
type SignedStorageAsk struct {
|
||||
Ask *StorageAsk
|
||||
Signature *Signature
|
||||
}
|
||||
type SignedStorageAsk = storagemarket.SignedStorageAsk
|
||||
|
||||
type StorageAsk struct {
|
||||
// Price per GiB / Epoch
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
type ActorType string
|
||||
|
||||
const (
|
||||
TAccount ActorType = "account"
|
||||
TMultisig ActorType = "multisig"
|
||||
|
@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"math"
|
||||
"os"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/ipfs/go-blockservice"
|
||||
@ -26,6 +26,8 @@ import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
@ -34,10 +36,9 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/impl/full"
|
||||
"github.com/filecoin-project/lotus/node/impl/paych"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
)
|
||||
|
||||
const dealStartBuffer abi.ChainEpoch 100
|
||||
const dealStartBuffer abi.ChainEpoch = 10000 // TODO: allow setting
|
||||
|
||||
type API struct {
|
||||
fx.In
|
||||
@ -80,16 +81,18 @@ func (a *API) ClientStartDeal(ctx context.Context, data cid.Cid, addr address.Ad
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed getting chain height: %w", err)
|
||||
}
|
||||
currentEpoch := ts.Height()
|
||||
result, err := a.SMDealClient.ProposeStorageDeal(
|
||||
ctx,
|
||||
addr,
|
||||
&providerInfo,
|
||||
data,
|
||||
&storagemarket.DataRef{
|
||||
TransferType: storagemarket.TTGraphsync,
|
||||
Root: data,
|
||||
},
|
||||
ts.Height()+dealStartBuffer,
|
||||
ts.Height()+dealStartBuffer+abi.ChainEpoch(blocksDuration),
|
||||
epochPrice,
|
||||
tokenamount.Empty)
|
||||
big.Zero())
|
||||
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to start deal: %w", err)
|
||||
@ -111,11 +114,11 @@ func (a *API) ClientListDeals(ctx context.Context) ([]api.DealInfo, error) {
|
||||
State: v.State,
|
||||
Provider: v.Proposal.Provider,
|
||||
|
||||
PieceRef: v.Proposal.PieceRef,
|
||||
Size: v.Proposal.PieceSize,
|
||||
PieceRef: v.Proposal.PieceCID.Bytes(),
|
||||
Size: uint64(v.Proposal.PieceSize.Unpadded()),
|
||||
|
||||
PricePerEpoch: v.Proposal.StoragePricePerEpoch,
|
||||
Duration: v.Proposal.Duration,
|
||||
Duration: uint64(v.Proposal.Duration()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,10 +135,10 @@ func (a *API) ClientGetDealInfo(ctx context.Context, d cid.Cid) (*api.DealInfo,
|
||||
ProposalCid: v.ProposalCid,
|
||||
State: v.State,
|
||||
Provider: v.Proposal.Provider,
|
||||
PieceRef: v.Proposal.PieceRef,
|
||||
Size: v.Proposal.PieceSize,
|
||||
PieceRef: v.Proposal.PieceCID.Bytes(),
|
||||
Size: uint64(v.Proposal.PieceSize.Unpadded()),
|
||||
PricePerEpoch: v.Proposal.StoragePricePerEpoch,
|
||||
Duration: v.Proposal.Duration,
|
||||
Duration: uint64(v.Proposal.Duration()),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -300,7 +303,7 @@ func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, path
|
||||
a.Retrieval.Retrieve(
|
||||
ctx,
|
||||
order.Root,
|
||||
retrievalmarket.NewParamsV0(types.BigDiv(order.Total, types.NewInt(order.Size)).Int, order.PaymentInterval, order.PaymentIntervalIncrease),
|
||||
retrievalmarket.NewParamsV0(types.BigDiv(order.Total, types.NewInt(order.Size)), order.PaymentInterval, order.PaymentIntervalIncrease),
|
||||
order.Total,
|
||||
order.MinerPeerID,
|
||||
order.Client,
|
||||
@ -327,11 +330,11 @@ func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, path
|
||||
return files.WriteTo(file, path)
|
||||
}
|
||||
|
||||
func (a *API) ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Address) (*types.SignedStorageAsk, error) {
|
||||
func (a *API) ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Address) (*storagemarket.SignedStorageAsk, error) {
|
||||
info := utils.NewStorageProviderInfo(miner, address.Undef, 0, p)
|
||||
signedAsk, err := a.SMDealClient.GetAsk(ctx, info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return signedAsk
|
||||
return signedAsk, nil
|
||||
}
|
||||
|
@ -107,7 +107,6 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
|
||||
SealEpoch: sector.Ticket.BlockHeight,
|
||||
DealIDs: nil, // sector.deals(), // TODO: REFACTOR
|
||||
},
|
||||
|
||||
}
|
||||
enc, aerr := actors.SerializeParams(params)
|
||||
if aerr != nil {
|
||||
@ -190,7 +189,7 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo)
|
||||
|
||||
params := &miner.ProveCommitSectorParams{
|
||||
SectorNumber: sector.SectorID,
|
||||
Proof: abi.SealProof{ProofBytes:proof},
|
||||
Proof: abi.SealProof{ProofBytes: proof},
|
||||
}
|
||||
|
||||
enc, aerr := actors.SerializeParams(params)
|
||||
|
Loading…
Reference in New Issue
Block a user