feat(retrieval): extract retrievalmarket
Extract retrieval market and modify shared types
This commit is contained in:
+3
-3
@@ -19,6 +19,8 @@ import (
|
||||
"go.uber.org/fx"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-fil-components/retrievalmarket"
|
||||
"github.com/filecoin-project/go-fil-components/retrievalmarket/discovery"
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/chain"
|
||||
"github.com/filecoin-project/lotus/chain/blocksync"
|
||||
@@ -43,8 +45,6 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
"github.com/filecoin-project/lotus/paych"
|
||||
"github.com/filecoin-project/lotus/peermgr"
|
||||
retrievalmarket "github.com/filecoin-project/lotus/retrieval"
|
||||
"github.com/filecoin-project/lotus/retrieval/discovery"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
||||
"github.com/filecoin-project/lotus/storagemarket"
|
||||
@@ -222,7 +222,7 @@ func Online() Option {
|
||||
Override(RunPeerMgrKey, modules.RunPeerMgr),
|
||||
Override(HandleIncomingBlocksKey, modules.HandleIncomingBlocks),
|
||||
|
||||
Override(new(*discovery.Local), discovery.NewLocal),
|
||||
Override(new(*discovery.Local), modules.NewLocalDiscovery),
|
||||
Override(new(retrievalmarket.PeerResolver), modules.RetrievalResolver),
|
||||
|
||||
Override(new(retrievalmarket.RetrievalClient), modules.RetrievalClient),
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"go.uber.org/fx"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-fil-components/retrievalmarket"
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
@@ -32,7 +33,7 @@ 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"
|
||||
retrievalmarket "github.com/filecoin-project/lotus/retrieval"
|
||||
"github.com/filecoin-project/lotus/retrievaladapter"
|
||||
"github.com/filecoin-project/lotus/storagemarket"
|
||||
)
|
||||
|
||||
@@ -164,7 +165,7 @@ func (a *API) ClientFindData(ctx context.Context, root cid.Cid) ([]api.QueryOffe
|
||||
out[k] = api.QueryOffer{
|
||||
Root: root,
|
||||
Size: queryResponse.Size,
|
||||
MinPrice: queryResponse.PieceRetrievalPrice(),
|
||||
MinPrice: retrievaladapter.FromSharedTokenAmount(queryResponse.PieceRetrievalPrice()),
|
||||
Miner: p.Address, // TODO: check
|
||||
MinerPeerID: p.ID,
|
||||
}
|
||||
@@ -292,9 +293,13 @@ func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, path
|
||||
})
|
||||
|
||||
a.Retrieval.Retrieve(
|
||||
ctx, order.Root.Bytes(), retrievalmarket.Params{
|
||||
PricePerByte: types.BigDiv(order.Total, types.NewInt(order.Size)),
|
||||
}, order.Total, order.MinerPeerID, order.Client, order.Miner)
|
||||
ctx,
|
||||
order.Root.Bytes(),
|
||||
retrievalmarket.NewParamsV0(types.BigDiv(order.Total, types.NewInt(order.Size)).Int, 0, 0),
|
||||
retrievaladapter.ToSharedTokenAmount(order.Total),
|
||||
order.MinerPeerID,
|
||||
order.Client,
|
||||
order.Miner)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return xerrors.New("Retrieval Timed Out")
|
||||
|
||||
@@ -6,11 +6,12 @@ import (
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
|
||||
"github.com/filecoin-project/go-fil-components/retrievalmarket"
|
||||
retrievalimpl "github.com/filecoin-project/go-fil-components/retrievalmarket/impl"
|
||||
"github.com/filecoin-project/go-statestore"
|
||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||
"github.com/filecoin-project/lotus/paych"
|
||||
retrievalmarket "github.com/filecoin-project/lotus/retrieval"
|
||||
retrievalimpl "github.com/filecoin-project/lotus/retrieval/impl"
|
||||
|
||||
"github.com/ipfs/go-bitswap"
|
||||
"github.com/ipfs/go-bitswap/network"
|
||||
graphsync "github.com/ipfs/go-graphsync/impl"
|
||||
|
||||
@@ -8,15 +8,16 @@ import (
|
||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||
"go.uber.org/fx"
|
||||
|
||||
"github.com/filecoin-project/go-fil-components/retrievalmarket"
|
||||
"github.com/filecoin-project/go-fil-components/retrievalmarket/discovery"
|
||||
"github.com/filecoin-project/lotus/chain"
|
||||
"github.com/filecoin-project/lotus/chain/blocksync"
|
||||
"github.com/filecoin-project/lotus/chain/messagepool"
|
||||
"github.com/filecoin-project/lotus/chain/sub"
|
||||
"github.com/filecoin-project/lotus/node/hello"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||
"github.com/filecoin-project/lotus/peermgr"
|
||||
retrievalmarket "github.com/filecoin-project/lotus/retrieval"
|
||||
"github.com/filecoin-project/lotus/retrieval/discovery"
|
||||
"github.com/filecoin-project/lotus/storagemarket"
|
||||
)
|
||||
|
||||
@@ -81,6 +82,10 @@ func RunDealClient(mctx helpers.MetricsCtx, lc fx.Lifecycle, c storagemarket.Sto
|
||||
})
|
||||
}
|
||||
|
||||
func NewLocalDiscovery(ds dtypes.MetadataDS) *discovery.Local {
|
||||
return discovery.NewLocal(ds)
|
||||
}
|
||||
|
||||
func RetrievalResolver(l *discovery.Local) retrievalmarket.PeerResolver {
|
||||
return discovery.Multi(l)
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
dtgraphsync "github.com/filecoin-project/go-data-transfer/impl/graphsync"
|
||||
"github.com/filecoin-project/go-fil-components/retrievalmarket"
|
||||
retrievalimpl "github.com/filecoin-project/go-fil-components/retrievalmarket/impl"
|
||||
"github.com/filecoin-project/go-sectorbuilder"
|
||||
"github.com/filecoin-project/go-statestore"
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
@@ -35,8 +37,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
retrievalmarket "github.com/filecoin-project/lotus/retrieval"
|
||||
retrievalimpl "github.com/filecoin-project/lotus/retrieval/impl"
|
||||
|
||||
"github.com/filecoin-project/lotus/retrievaladapter"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
||||
@@ -265,6 +266,6 @@ func SealTicketGen(api api.FullNode) storage.TicketFn {
|
||||
|
||||
// RetrievalProvider creates a new retrieval provider attached to the provider blockstore
|
||||
func RetrievalProvider(sblks *sectorblocks.SectorBlocks, full api.FullNode) retrievalmarket.RetrievalProvider {
|
||||
adapter := retrievaladapter.NewRetrievalProviderNode(full)
|
||||
return retrievalimpl.NewProvider(sblks, adapter)
|
||||
adapter := retrievaladapter.NewRetrievalProviderNode(sblks, full)
|
||||
return retrievalimpl.NewProvider(adapter)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user