Fix client market impl, gofmt
This commit is contained in:
parent
91b2d2c2fe
commit
e5ab64a3ab
@ -183,7 +183,6 @@ func (st *StateTree) RegisterNewAddress(addr address.Address, act *types.Actor)
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type adtStore struct{ cbor.IpldStore }
|
type adtStore struct{ cbor.IpldStore }
|
||||||
|
|
||||||
func (a *adtStore) Context() context.Context {
|
func (a *adtStore) Context() context.Context {
|
||||||
|
@ -2,6 +2,7 @@ package types
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -10,10 +11,7 @@ func init() {
|
|||||||
cbor.RegisterCborType(StorageAsk{})
|
cbor.RegisterCborType(StorageAsk{})
|
||||||
}
|
}
|
||||||
|
|
||||||
type SignedStorageAsk struct {
|
type SignedStorageAsk = storagemarket.SignedStorageAsk
|
||||||
Ask *StorageAsk
|
|
||||||
Signature *Signature
|
|
||||||
}
|
|
||||||
|
|
||||||
type StorageAsk struct {
|
type StorageAsk struct {
|
||||||
// Price per GiB / Epoch
|
// Price per GiB / Epoch
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ActorType string
|
type ActorType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TAccount ActorType = "account"
|
TAccount ActorType = "account"
|
||||||
TMultisig ActorType = "multisig"
|
TMultisig ActorType = "multisig"
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/ipfs/go-blockservice"
|
"github.com/ipfs/go-blockservice"
|
||||||
@ -26,6 +26,8 @@ import (
|
|||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
||||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
"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/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"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/full"
|
||||||
"github.com/filecoin-project/lotus/node/impl/paych"
|
"github.com/filecoin-project/lotus/node/impl/paych"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"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 {
|
type API struct {
|
||||||
fx.In
|
fx.In
|
||||||
@ -80,16 +81,18 @@ func (a *API) ClientStartDeal(ctx context.Context, data cid.Cid, addr address.Ad
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed getting chain height: %w", err)
|
return nil, xerrors.Errorf("failed getting chain height: %w", err)
|
||||||
}
|
}
|
||||||
currentEpoch := ts.Height()
|
|
||||||
result, err := a.SMDealClient.ProposeStorageDeal(
|
result, err := a.SMDealClient.ProposeStorageDeal(
|
||||||
ctx,
|
ctx,
|
||||||
addr,
|
addr,
|
||||||
&providerInfo,
|
&providerInfo,
|
||||||
data,
|
&storagemarket.DataRef{
|
||||||
|
TransferType: storagemarket.TTGraphsync,
|
||||||
|
Root: data,
|
||||||
|
},
|
||||||
ts.Height()+dealStartBuffer,
|
ts.Height()+dealStartBuffer,
|
||||||
ts.Height()+dealStartBuffer+abi.ChainEpoch(blocksDuration),
|
ts.Height()+dealStartBuffer+abi.ChainEpoch(blocksDuration),
|
||||||
epochPrice,
|
epochPrice,
|
||||||
tokenamount.Empty)
|
big.Zero())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed to start deal: %w", err)
|
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,
|
State: v.State,
|
||||||
Provider: v.Proposal.Provider,
|
Provider: v.Proposal.Provider,
|
||||||
|
|
||||||
PieceRef: v.Proposal.PieceRef,
|
PieceRef: v.Proposal.PieceCID.Bytes(),
|
||||||
Size: v.Proposal.PieceSize,
|
Size: uint64(v.Proposal.PieceSize.Unpadded()),
|
||||||
|
|
||||||
PricePerEpoch: v.Proposal.StoragePricePerEpoch,
|
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,
|
ProposalCid: v.ProposalCid,
|
||||||
State: v.State,
|
State: v.State,
|
||||||
Provider: v.Proposal.Provider,
|
Provider: v.Proposal.Provider,
|
||||||
PieceRef: v.Proposal.PieceRef,
|
PieceRef: v.Proposal.PieceCID.Bytes(),
|
||||||
Size: v.Proposal.PieceSize,
|
Size: uint64(v.Proposal.PieceSize.Unpadded()),
|
||||||
PricePerEpoch: v.Proposal.StoragePricePerEpoch,
|
PricePerEpoch: v.Proposal.StoragePricePerEpoch,
|
||||||
Duration: v.Proposal.Duration,
|
Duration: uint64(v.Proposal.Duration()),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +303,7 @@ func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, path
|
|||||||
a.Retrieval.Retrieve(
|
a.Retrieval.Retrieve(
|
||||||
ctx,
|
ctx,
|
||||||
order.Root,
|
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.Total,
|
||||||
order.MinerPeerID,
|
order.MinerPeerID,
|
||||||
order.Client,
|
order.Client,
|
||||||
@ -327,11 +330,11 @@ func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, path
|
|||||||
return files.WriteTo(file, 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)
|
info := utils.NewStorageProviderInfo(miner, address.Undef, 0, p)
|
||||||
signedAsk, err := a.SMDealClient.GetAsk(ctx, info)
|
signedAsk, err := a.SMDealClient.GetAsk(ctx, info)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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,
|
SealEpoch: sector.Ticket.BlockHeight,
|
||||||
DealIDs: nil, // sector.deals(), // TODO: REFACTOR
|
DealIDs: nil, // sector.deals(), // TODO: REFACTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
enc, aerr := actors.SerializeParams(params)
|
enc, aerr := actors.SerializeParams(params)
|
||||||
if aerr != nil {
|
if aerr != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user