refactor(datatransfer): move registrations to builder
move registration function for validators to builder code
This commit is contained in:
+2
-2
@@ -224,7 +224,7 @@ func Online() Option {
|
||||
Override(new(datatransfer.ClientDataTransfer), datatransfer.NewClientDAGServiceDataTransfer),
|
||||
Override(new(*deals.ClientRequestValidator), deals.NewClientRequestValidator),
|
||||
Override(new(*deals.Client), deals.NewClient),
|
||||
Override(RegisterClientValidatorKey, deals.RegisterClientValidator),
|
||||
Override(RegisterClientValidatorKey, modules.RegisterClientValidator),
|
||||
Override(RunDealClientKey, modules.RunDealClient),
|
||||
|
||||
Override(new(*paych.Store), paych.NewStore),
|
||||
@@ -247,7 +247,7 @@ func Online() Option {
|
||||
Override(new(datatransfer.ProviderDataTransfer), datatransfer.NewProviderDAGServiceDataTransfer),
|
||||
Override(new(*deals.ProviderRequestValidator), deals.NewProviderRequestValidator),
|
||||
Override(new(*deals.Provider), deals.NewProvider),
|
||||
Override(RegisterProviderValidatorKey, deals.RegisterProviderValidator),
|
||||
Override(RegisterProviderValidatorKey, modules.RegisterProviderValidator),
|
||||
Override(HandleRetrievalKey, modules.HandleRetrieval),
|
||||
Override(HandleDealsKey, modules.HandleDeals),
|
||||
Override(RegisterMinerKey, modules.RegisterMiner),
|
||||
|
||||
+12
-1
@@ -2,12 +2,14 @@ package modules
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
|
||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||
"github.com/ipfs/go-bitswap"
|
||||
"github.com/ipfs/go-bitswap/network"
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p-core/routing"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/ipfs/go-blockservice"
|
||||
"github.com/ipfs/go-datastore"
|
||||
@@ -17,6 +19,8 @@ import (
|
||||
"github.com/ipfs/go-merkledag"
|
||||
"go.uber.org/fx"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/deals"
|
||||
"github.com/filecoin-project/lotus/datatransfer"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
)
|
||||
@@ -40,6 +44,13 @@ func ClientBlockstore(fstore dtypes.ClientFilestore) dtypes.ClientBlockstore {
|
||||
return blockstore.NewIdStore((*filestore.Filestore)(fstore))
|
||||
}
|
||||
|
||||
// RegisterClientValidator is an initialization hook that registers the client
|
||||
// request validator with the data transfer module as the validator for
|
||||
// StorageDataTransferVoucher types
|
||||
func RegisterClientValidator(crv *deals.ClientRequestValidator, dtm datatransfer.ClientDataTransfer) {
|
||||
dtm.RegisterVoucherType(reflect.TypeOf(deals.StorageDataTransferVoucher{}), crv)
|
||||
}
|
||||
|
||||
func ClientDAG(mctx helpers.MetricsCtx, lc fx.Lifecycle, ibs dtypes.ClientBlockstore, rt routing.Routing, h host.Host) dtypes.ClientDAG {
|
||||
bitswapNetwork := network.NewFromIpfsHost(h, rt)
|
||||
exch := bitswap.New(helpers.LifecycleCtx(mctx, lc), bitswapNetwork, ibs)
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
|
||||
"github.com/ipfs/go-bitswap"
|
||||
"github.com/ipfs/go-bitswap/network"
|
||||
@@ -22,6 +23,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/address"
|
||||
"github.com/filecoin-project/lotus/chain/deals"
|
||||
"github.com/filecoin-project/lotus/datatransfer"
|
||||
"github.com/filecoin-project/lotus/lib/sectorbuilder"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||
@@ -130,6 +132,13 @@ func HandleDeals(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, h *de
|
||||
})
|
||||
}
|
||||
|
||||
// RegisterProviderValidator is an initialization hook that registers the provider
|
||||
// request validator with the data transfer module as the validator for
|
||||
// StorageDataTransferVoucher types
|
||||
func RegisterProviderValidator(mrv *deals.ProviderRequestValidator, dtm datatransfer.ProviderDataTransfer) {
|
||||
dtm.RegisterVoucherType(reflect.TypeOf(deals.StorageDataTransferVoucher{}), mrv)
|
||||
}
|
||||
|
||||
func StagingDAG(mctx helpers.MetricsCtx, lc fx.Lifecycle, r repo.LockedRepo, rt routing.Routing, h host.Host) (dtypes.StagingDAG, error) {
|
||||
stagingds, err := r.Datastore("/staging")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user