feat(markets): update to 0.5.4
This commit is contained in:
parent
6b8f27264b
commit
a89c290f62
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
|
||||||
"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/storagemarket"
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||||
"github.com/filecoin-project/go-multistore"
|
"github.com/filecoin-project/go-multistore"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
@ -523,7 +524,7 @@ type QueryOffer struct {
|
|||||||
PaymentInterval uint64
|
PaymentInterval uint64
|
||||||
PaymentIntervalIncrease uint64
|
PaymentIntervalIncrease uint64
|
||||||
Miner address.Address
|
Miner address.Address
|
||||||
MinerPeerID peer.ID
|
MinerPeer retrievalmarket.RetrievalPeer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *QueryOffer) Order(client address.Address) RetrievalOrder {
|
func (o *QueryOffer) Order(client address.Address) RetrievalOrder {
|
||||||
@ -537,8 +538,8 @@ func (o *QueryOffer) Order(client address.Address) RetrievalOrder {
|
|||||||
PaymentIntervalIncrease: o.PaymentIntervalIncrease,
|
PaymentIntervalIncrease: o.PaymentIntervalIncrease,
|
||||||
Client: client,
|
Client: client,
|
||||||
|
|
||||||
Miner: o.Miner,
|
Miner: o.Miner,
|
||||||
MinerPeerID: o.MinerPeerID,
|
MinerPeer: o.MinerPeer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -564,7 +565,7 @@ type RetrievalOrder struct {
|
|||||||
PaymentIntervalIncrease uint64
|
PaymentIntervalIncrease uint64
|
||||||
Client address.Address
|
Client address.Address
|
||||||
Miner address.Address
|
Miner address.Address
|
||||||
MinerPeerID peer.ID
|
MinerPeer retrievalmarket.RetrievalPeer
|
||||||
}
|
}
|
||||||
|
|
||||||
type InvocResult struct {
|
type InvocResult struct {
|
||||||
|
@ -689,10 +689,10 @@ var clientFindCmd = &cli.Command{
|
|||||||
|
|
||||||
for _, offer := range offers {
|
for _, offer := range offers {
|
||||||
if offer.Err != "" {
|
if offer.Err != "" {
|
||||||
fmt.Printf("ERR %s@%s: %s\n", offer.Miner, offer.MinerPeerID, offer.Err)
|
fmt.Printf("ERR %s@%s: %s\n", offer.Miner, offer.MinerPeer.ID, offer.Err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fmt.Printf("RETRIEVAL %s@%s-%s-%s\n", offer.Miner, offer.MinerPeerID, types.FIL(offer.MinPrice), types.SizeStr(types.NewInt(offer.Size)))
|
fmt.Printf("RETRIEVAL %s@%s-%s-%s\n", offer.Miner, offer.MinerPeer.ID, types.FIL(offer.MinPrice), types.SizeStr(types.NewInt(offer.Size)))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
2
go.mod
2
go.mod
@ -27,7 +27,7 @@ require (
|
|||||||
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03
|
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03
|
||||||
github.com/filecoin-project/go-data-transfer v0.5.3
|
github.com/filecoin-project/go-data-transfer v0.5.3
|
||||||
github.com/filecoin-project/go-fil-commcid v0.0.0-20200716160307-8f644712406f
|
github.com/filecoin-project/go-fil-commcid v0.0.0-20200716160307-8f644712406f
|
||||||
github.com/filecoin-project/go-fil-markets v0.5.3
|
github.com/filecoin-project/go-fil-markets v0.5.4-0.20200805221213-333079b9f648
|
||||||
github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24
|
github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24
|
||||||
github.com/filecoin-project/go-multistore v0.0.3
|
github.com/filecoin-project/go-multistore v0.0.3
|
||||||
github.com/filecoin-project/go-padreader v0.0.0-20200210211231-548257017ca6
|
github.com/filecoin-project/go-padreader v0.0.0-20200210211231-548257017ca6
|
||||||
|
2
go.sum
2
go.sum
@ -243,6 +243,8 @@ github.com/filecoin-project/go-fil-commcid v0.0.0-20200716160307-8f644712406f h1
|
|||||||
github.com/filecoin-project/go-fil-commcid v0.0.0-20200716160307-8f644712406f/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ=
|
github.com/filecoin-project/go-fil-commcid v0.0.0-20200716160307-8f644712406f/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ=
|
||||||
github.com/filecoin-project/go-fil-markets v0.5.3 h1:BjEfUIe/ov95jt7K9m9F/ZEJsvdlJAstSPfNyBXcPd0=
|
github.com/filecoin-project/go-fil-markets v0.5.3 h1:BjEfUIe/ov95jt7K9m9F/ZEJsvdlJAstSPfNyBXcPd0=
|
||||||
github.com/filecoin-project/go-fil-markets v0.5.3/go.mod h1:RNaiPhWF8xPrb9oUWJK7FGfD1jkdsk4XjCwczKpwnX0=
|
github.com/filecoin-project/go-fil-markets v0.5.3/go.mod h1:RNaiPhWF8xPrb9oUWJK7FGfD1jkdsk4XjCwczKpwnX0=
|
||||||
|
github.com/filecoin-project/go-fil-markets v0.5.4-0.20200805221213-333079b9f648 h1:JdxaUXnFUNLAu6K0ollDponhqg6q4h6vv9IMwtJEEKM=
|
||||||
|
github.com/filecoin-project/go-fil-markets v0.5.4-0.20200805221213-333079b9f648/go.mod h1:RNaiPhWF8xPrb9oUWJK7FGfD1jkdsk4XjCwczKpwnX0=
|
||||||
github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24 h1:Jc7vkplmZYVuaEcSXGHDwefvZIdoyyaoGDLqSr8Svms=
|
github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24 h1:Jc7vkplmZYVuaEcSXGHDwefvZIdoyyaoGDLqSr8Svms=
|
||||||
github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24/go.mod h1:j6zV//WXIIY5kky873Q3iIKt/ViOE8rcijovmpxrXzM=
|
github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24/go.mod h1:j6zV//WXIIY5kky873Q3iIKt/ViOE8rcijovmpxrXzM=
|
||||||
github.com/filecoin-project/go-multistore v0.0.3 h1:vaRBY4YiA2UZFPK57RNuewypB8u0DzzQwqsL0XarpnI=
|
github.com/filecoin-project/go-multistore v0.0.3 h1:vaRBY4YiA2UZFPK57RNuewypB8u0DzzQwqsL0XarpnI=
|
||||||
|
@ -12,24 +12,27 @@ import (
|
|||||||
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
||||||
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
|
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
|
"github.com/multiformats/go-multiaddr"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/node/impl/full"
|
"github.com/filecoin-project/lotus/node/impl/full"
|
||||||
payapi "github.com/filecoin-project/lotus/node/impl/paych"
|
payapi "github.com/filecoin-project/lotus/node/impl/paych"
|
||||||
"github.com/filecoin-project/lotus/paychmgr"
|
"github.com/filecoin-project/lotus/paychmgr"
|
||||||
)
|
)
|
||||||
|
|
||||||
type retrievalClientNode struct {
|
type retrievalClientNode struct {
|
||||||
chainapi full.ChainAPI
|
chainAPI full.ChainAPI
|
||||||
pmgr *paychmgr.Manager
|
pmgr *paychmgr.Manager
|
||||||
payapi payapi.PaychAPI
|
payAPI payapi.PaychAPI
|
||||||
|
stateAPI full.StateAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRetrievalClientNode returns a new node adapter for a retrieval client that talks to the
|
// NewRetrievalClientNode returns a new node adapter for a retrieval client that talks to the
|
||||||
// Lotus Node
|
// Lotus Node
|
||||||
func NewRetrievalClientNode(pmgr *paychmgr.Manager, payapi payapi.PaychAPI, chainapi full.ChainAPI) retrievalmarket.RetrievalClientNode {
|
func NewRetrievalClientNode(pmgr *paychmgr.Manager, payAPI payapi.PaychAPI, chainAPI full.ChainAPI, stateAPI full.StateAPI) retrievalmarket.RetrievalClientNode {
|
||||||
return &retrievalClientNode{pmgr: pmgr, payapi: payapi, chainapi: chainapi}
|
return &retrievalClientNode{pmgr: pmgr, payAPI: payAPI, chainAPI: chainAPI, stateAPI: stateAPI}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOrCreatePaymentChannel sets up a new payment channel if one does not exist
|
// GetOrCreatePaymentChannel sets up a new payment channel if one does not exist
|
||||||
@ -54,7 +57,7 @@ func (rcn *retrievalClientNode) AllocateLane(paymentChannel address.Address) (ui
|
|||||||
func (rcn *retrievalClientNode) CreatePaymentVoucher(ctx context.Context, paymentChannel address.Address, amount abi.TokenAmount, lane uint64, tok shared.TipSetToken) (*paych.SignedVoucher, error) {
|
func (rcn *retrievalClientNode) CreatePaymentVoucher(ctx context.Context, paymentChannel address.Address, amount abi.TokenAmount, lane uint64, tok shared.TipSetToken) (*paych.SignedVoucher, error) {
|
||||||
// TODO: respect the provided TipSetToken (a serialized TipSetKey) when
|
// TODO: respect the provided TipSetToken (a serialized TipSetKey) when
|
||||||
// querying the chain
|
// querying the chain
|
||||||
voucher, err := rcn.payapi.PaychVoucherCreate(ctx, paymentChannel, amount, lane)
|
voucher, err := rcn.payAPI.PaychVoucherCreate(ctx, paymentChannel, amount, lane)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -62,7 +65,7 @@ func (rcn *retrievalClientNode) CreatePaymentVoucher(ctx context.Context, paymen
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rcn *retrievalClientNode) GetChainHead(ctx context.Context) (shared.TipSetToken, abi.ChainEpoch, error) {
|
func (rcn *retrievalClientNode) GetChainHead(ctx context.Context) (shared.TipSetToken, abi.ChainEpoch, error) {
|
||||||
head, err := rcn.chainapi.ChainHead(ctx)
|
head, err := rcn.chainAPI.ChainHead(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
@ -73,7 +76,7 @@ func (rcn *retrievalClientNode) GetChainHead(ctx context.Context) (shared.TipSet
|
|||||||
// WaitForPaymentChannelAddFunds waits messageCID to appear on chain. If it doesn't appear within
|
// WaitForPaymentChannelAddFunds waits messageCID to appear on chain. If it doesn't appear within
|
||||||
// defaultMsgWaitTimeout it returns error
|
// defaultMsgWaitTimeout it returns error
|
||||||
func (rcn *retrievalClientNode) WaitForPaymentChannelAddFunds(messageCID cid.Cid) error {
|
func (rcn *retrievalClientNode) WaitForPaymentChannelAddFunds(messageCID cid.Cid) error {
|
||||||
_, mr, err := rcn.chainapi.StateManager.WaitForMessage(context.TODO(), messageCID, build.MessageConfidence)
|
_, mr, err := rcn.chainAPI.StateManager.WaitForMessage(context.TODO(), messageCID, build.MessageConfidence)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -85,7 +88,7 @@ func (rcn *retrievalClientNode) WaitForPaymentChannelAddFunds(messageCID cid.Cid
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rcn *retrievalClientNode) WaitForPaymentChannelCreation(messageCID cid.Cid) (address.Address, error) {
|
func (rcn *retrievalClientNode) WaitForPaymentChannelCreation(messageCID cid.Cid) (address.Address, error) {
|
||||||
_, mr, err := rcn.chainapi.StateManager.WaitForMessage(context.TODO(), messageCID, build.MessageConfidence)
|
_, mr, err := rcn.chainAPI.StateManager.WaitForMessage(context.TODO(), messageCID, build.MessageConfidence)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return address.Undef, err
|
return address.Undef, err
|
||||||
@ -99,3 +102,24 @@ func (rcn *retrievalClientNode) WaitForPaymentChannelCreation(messageCID cid.Cid
|
|||||||
}
|
}
|
||||||
return retval.RobustAddress, nil
|
return retval.RobustAddress, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rcn *retrievalClientNode) GetKnownAddresses(ctx context.Context, p retrievalmarket.RetrievalPeer, encodedTs shared.TipSetToken) ([]multiaddr.Multiaddr, error) {
|
||||||
|
tsk, err := types.TipSetKeyFromBytes(encodedTs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
mi, err := rcn.stateAPI.StateMinerInfo(ctx, p.Address, tsk)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
multiaddrs := make([]multiaddr.Multiaddr, 0, len(mi.Multiaddrs))
|
||||||
|
for _, a := range mi.Multiaddrs {
|
||||||
|
maddr, err := multiaddr.NewMultiaddrBytes(a)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
multiaddrs = append(multiaddrs, maddr)
|
||||||
|
}
|
||||||
|
|
||||||
|
return multiaddrs, nil
|
||||||
|
}
|
||||||
|
@ -29,6 +29,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-fil-markets/pieceio"
|
"github.com/filecoin-project/go-fil-markets/pieceio"
|
||||||
|
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
||||||
rm "github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
rm "github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
||||||
"github.com/filecoin-project/go-fil-markets/shared"
|
"github.com/filecoin-project/go-fil-markets/shared"
|
||||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||||
@ -260,7 +261,7 @@ func (a *API) ClientMinerQueryOffer(ctx context.Context, miner address.Address,
|
|||||||
func (a *API) makeRetrievalQuery(ctx context.Context, rp rm.RetrievalPeer, payload cid.Cid, piece *cid.Cid, qp rm.QueryParams) api.QueryOffer {
|
func (a *API) makeRetrievalQuery(ctx context.Context, rp rm.RetrievalPeer, payload cid.Cid, piece *cid.Cid, qp rm.QueryParams) api.QueryOffer {
|
||||||
queryResponse, err := a.Retrieval.Query(ctx, rp, payload, qp)
|
queryResponse, err := a.Retrieval.Query(ctx, rp, payload, qp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.QueryOffer{Err: err.Error(), Miner: rp.Address, MinerPeerID: rp.ID}
|
return api.QueryOffer{Err: err.Error(), Miner: rp.Address, MinerPeer: rp}
|
||||||
}
|
}
|
||||||
var errStr string
|
var errStr string
|
||||||
switch queryResponse.Status {
|
switch queryResponse.Status {
|
||||||
@ -281,7 +282,7 @@ func (a *API) makeRetrievalQuery(ctx context.Context, rp rm.RetrievalPeer, paylo
|
|||||||
PaymentInterval: queryResponse.MaxPaymentInterval,
|
PaymentInterval: queryResponse.MaxPaymentInterval,
|
||||||
PaymentIntervalIncrease: queryResponse.MaxPaymentIntervalIncrease,
|
PaymentIntervalIncrease: queryResponse.MaxPaymentIntervalIncrease,
|
||||||
Miner: queryResponse.PaymentAddress, // TODO: check
|
Miner: queryResponse.PaymentAddress, // TODO: check
|
||||||
MinerPeerID: rp.ID,
|
MinerPeer: rp,
|
||||||
Err: errStr,
|
Err: errStr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -398,13 +399,16 @@ func (a *API) ClientListImports(ctx context.Context) ([]api.Import, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, ref *api.FileRef) error {
|
func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, ref *api.FileRef) error {
|
||||||
if order.MinerPeerID == "" {
|
if order.MinerPeer.ID == "" {
|
||||||
mi, err := a.StateMinerInfo(ctx, order.Miner, types.EmptyTSK)
|
mi, err := a.StateMinerInfo(ctx, order.Miner, types.EmptyTSK)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
order.MinerPeerID = mi.PeerId
|
order.MinerPeer = retrievalmarket.RetrievalPeer{
|
||||||
|
ID: mi.PeerId,
|
||||||
|
Address: order.Miner,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if order.Size == 0 {
|
if order.Size == 0 {
|
||||||
@ -457,7 +461,7 @@ func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, ref
|
|||||||
order.Root,
|
order.Root,
|
||||||
params,
|
params,
|
||||||
order.Total,
|
order.Total,
|
||||||
order.MinerPeerID,
|
order.MinerPeer,
|
||||||
order.Client,
|
order.Client,
|
||||||
order.Miner,
|
order.Miner,
|
||||||
store.StoreID())
|
store.StoreID())
|
||||||
|
@ -141,8 +141,8 @@ func StorageClient(lc fx.Lifecycle, h host.Host, ibs dtypes.ClientBlockstore, md
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RetrievalClient creates a new retrieval client attached to the client blockstore
|
// RetrievalClient creates a new retrieval client attached to the client blockstore
|
||||||
func RetrievalClient(lc fx.Lifecycle, h host.Host, mds dtypes.ClientMultiDstore, dt dtypes.ClientDataTransfer, pmgr *paychmgr.Manager, payapi payapi.PaychAPI, resolver retrievalmarket.PeerResolver, ds dtypes.MetadataDS, chainapi full.ChainAPI) (retrievalmarket.RetrievalClient, error) {
|
func RetrievalClient(lc fx.Lifecycle, h host.Host, mds dtypes.ClientMultiDstore, dt dtypes.ClientDataTransfer, pmgr *paychmgr.Manager, payAPI payapi.PaychAPI, resolver retrievalmarket.PeerResolver, ds dtypes.MetadataDS, chainAPI full.ChainAPI, stateAPI full.StateAPI) (retrievalmarket.RetrievalClient, error) {
|
||||||
adapter := retrievaladapter.NewRetrievalClientNode(pmgr, payapi, chainapi)
|
adapter := retrievaladapter.NewRetrievalClientNode(pmgr, payAPI, chainAPI, stateAPI)
|
||||||
network := rmnet.NewFromLibp2pHost(h)
|
network := rmnet.NewFromLibp2pHost(h)
|
||||||
sc := storedcounter.New(ds, datastore.NewKey("/retr"))
|
sc := storedcounter.New(ds, datastore.NewKey("/retr"))
|
||||||
client, err := retrievalimpl.NewClient(network, mds, dt, adapter, resolver, namespace.Wrap(ds, datastore.NewKey("/retrievals/client")), sc)
|
client, err := retrievalimpl.NewClient(network, mds, dt, adapter, resolver, namespace.Wrap(ds, datastore.NewKey("/retrievals/client")), sc)
|
||||||
|
Loading…
Reference in New Issue
Block a user