node builder: Cleanup and add some docstrings
This commit is contained in:
parent
811fb44dd0
commit
adeb4cefee
227
node/builder.go
227
node/builder.go
@ -171,6 +171,7 @@ type Settings struct {
|
|||||||
Lite bool // Start node in "lite" mode
|
Lite bool // Start node in "lite" mode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Basic lotus-app services
|
||||||
func defaults() []Option {
|
func defaults() []Option {
|
||||||
return []Option{
|
return []Option{
|
||||||
// global system journal.
|
// global system journal.
|
||||||
@ -184,40 +185,44 @@ func defaults() []Option {
|
|||||||
return metricsi.CtxScope(context.Background(), "lotus")
|
return metricsi.CtxScope(context.Background(), "lotus")
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Override(new(record.Validator), modules.RecordValidator),
|
|
||||||
Override(new(dtypes.Bootstrapper), dtypes.Bootstrapper(false)),
|
|
||||||
Override(new(dtypes.ShutdownChan), make(chan struct{})),
|
Override(new(dtypes.ShutdownChan), make(chan struct{})),
|
||||||
|
|
||||||
// Filecoin modules
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func libp2p() Option {
|
var LibP2P = Options(
|
||||||
return Options(
|
// Host config
|
||||||
|
Override(new(dtypes.Bootstrapper), dtypes.Bootstrapper(false)),
|
||||||
|
|
||||||
|
// Host dependencies
|
||||||
Override(new(peerstore.Peerstore), pstoremem.NewPeerstore),
|
Override(new(peerstore.Peerstore), pstoremem.NewPeerstore),
|
||||||
|
Override(PstoreAddSelfKeysKey, lp2p.PstoreAddSelfKeys),
|
||||||
|
Override(StartListeningKey, lp2p.StartListening(config.DefaultFullNode().Libp2p.ListenAddresses)),
|
||||||
|
|
||||||
|
// Host settings
|
||||||
Override(DefaultTransportsKey, lp2p.DefaultTransports),
|
Override(DefaultTransportsKey, lp2p.DefaultTransports),
|
||||||
|
|
||||||
Override(new(lp2p.RawHost), lp2p.Host),
|
|
||||||
Override(new(host.Host), lp2p.RoutedHost),
|
|
||||||
Override(new(lp2p.BaseIpfsRouting), lp2p.DHTRouting(dht.ModeAuto)),
|
|
||||||
|
|
||||||
Override(DiscoveryHandlerKey, lp2p.DiscoveryHandler),
|
|
||||||
Override(AddrsFactoryKey, lp2p.AddrsFactory(nil, nil)),
|
Override(AddrsFactoryKey, lp2p.AddrsFactory(nil, nil)),
|
||||||
Override(SmuxTransportKey, lp2p.SmuxTransport(true)),
|
Override(SmuxTransportKey, lp2p.SmuxTransport(true)),
|
||||||
Override(RelayKey, lp2p.NoRelay()),
|
Override(RelayKey, lp2p.NoRelay()),
|
||||||
Override(SecurityKey, lp2p.Security(true, false)),
|
Override(SecurityKey, lp2p.Security(true, false)),
|
||||||
|
|
||||||
|
// Host
|
||||||
|
Override(new(lp2p.RawHost), lp2p.Host),
|
||||||
|
Override(new(host.Host), lp2p.RoutedHost),
|
||||||
|
Override(new(lp2p.BaseIpfsRouting), lp2p.DHTRouting(dht.ModeAuto)),
|
||||||
|
|
||||||
|
Override(DiscoveryHandlerKey, lp2p.DiscoveryHandler),
|
||||||
|
|
||||||
|
// Routing
|
||||||
|
Override(new(record.Validator), modules.RecordValidator),
|
||||||
Override(BaseRoutingKey, lp2p.BaseRouting),
|
Override(BaseRoutingKey, lp2p.BaseRouting),
|
||||||
Override(new(routing.Routing), lp2p.Routing),
|
Override(new(routing.Routing), lp2p.Routing),
|
||||||
|
|
||||||
|
// Services
|
||||||
Override(NatPortMapKey, lp2p.NatPortMap),
|
Override(NatPortMapKey, lp2p.NatPortMap),
|
||||||
Override(BandwidthReporterKey, lp2p.BandwidthCounter),
|
Override(BandwidthReporterKey, lp2p.BandwidthCounter),
|
||||||
|
|
||||||
Override(ConnectionManagerKey, lp2p.ConnectionManager(50, 200, 20*time.Second, nil)),
|
|
||||||
Override(AutoNATSvcKey, lp2p.AutoNATService),
|
Override(AutoNATSvcKey, lp2p.AutoNATService),
|
||||||
|
|
||||||
|
// Services (pubsub)
|
||||||
Override(new(*dtypes.ScoreKeeper), lp2p.ScoreKeeper),
|
Override(new(*dtypes.ScoreKeeper), lp2p.ScoreKeeper),
|
||||||
Override(new(*pubsub.PubSub), lp2p.GossipSub),
|
Override(new(*pubsub.PubSub), lp2p.GossipSub),
|
||||||
Override(new(*config.Pubsub), func(bs dtypes.Bootstrapper) *config.Pubsub {
|
Override(new(*config.Pubsub), func(bs dtypes.Bootstrapper) *config.Pubsub {
|
||||||
@ -226,97 +231,103 @@ func libp2p() Option {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Override(PstoreAddSelfKeysKey, lp2p.PstoreAddSelfKeys),
|
// Services (connection management)
|
||||||
Override(StartListeningKey, lp2p.StartListening(config.DefaultFullNode().Libp2p.ListenAddresses)),
|
Override(ConnectionManagerKey, lp2p.ConnectionManager(50, 200, 20*time.Second, nil)),
|
||||||
|
|
||||||
Override(new(*conngater.BasicConnectionGater), lp2p.ConnGater),
|
Override(new(*conngater.BasicConnectionGater), lp2p.ConnGater),
|
||||||
Override(ConnGaterKey, lp2p.ConnGaterOption),
|
Override(ConnGaterKey, lp2p.ConnGaterOption),
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
func isType(t repo.RepoType) func(s *Settings) bool {
|
func isType(t repo.RepoType) func(s *Settings) bool {
|
||||||
return func(s *Settings) bool { return s.nodeType == t }
|
return func(s *Settings) bool { return s.nodeType == t }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Online sets up basic libp2p node
|
func isFullOrLiteNode(s *Settings) bool { return s.nodeType == repo.FullNode }
|
||||||
func Online() Option {
|
func isFullNode(s *Settings) bool { return s.nodeType == repo.FullNode && !s.Lite }
|
||||||
isFullOrLiteNode := func(s *Settings) bool { return s.nodeType == repo.FullNode }
|
func isLiteNode(s *Settings) bool { return s.nodeType == repo.FullNode && s.Lite }
|
||||||
isFullNode := func(s *Settings) bool { return s.nodeType == repo.FullNode && !s.Lite }
|
|
||||||
isLiteNode := func(s *Settings) bool { return s.nodeType == repo.FullNode && s.Lite }
|
|
||||||
|
|
||||||
return Options(
|
|
||||||
// make sure that online is applied before Config.
|
|
||||||
// This is important because Config overrides some of Online units
|
|
||||||
func(s *Settings) error { s.Online = true; return nil },
|
|
||||||
ApplyIf(func(s *Settings) bool { return s.Config },
|
|
||||||
Error(errors.New("the Online option must be set before Config option")),
|
|
||||||
),
|
|
||||||
|
|
||||||
libp2p(),
|
|
||||||
|
|
||||||
// common
|
|
||||||
Override(new(*slashfilter.SlashFilter), modules.NewSlashFilter),
|
|
||||||
|
|
||||||
|
// Chain node provides access to the Filecoin blockchain, by setting up a full
|
||||||
|
// validator node, or by delegating some actions to other nodes (lite mode)
|
||||||
|
var ChainNode = Options(
|
||||||
// Full node or lite node
|
// Full node or lite node
|
||||||
ApplyIf(isFullOrLiteNode,
|
|
||||||
// TODO: Fix offline mode
|
// TODO: Fix offline mode
|
||||||
|
|
||||||
|
// Consensus settings
|
||||||
|
Override(new(dtypes.DrandSchedule), modules.BuiltinDrandConfig),
|
||||||
|
Override(new(stmgr.UpgradeSchedule), stmgr.DefaultUpgradeSchedule()),
|
||||||
|
Override(new(dtypes.NetworkName), modules.NetworkName),
|
||||||
|
Override(new(modules.Genesis), modules.ErrorGenesis),
|
||||||
|
Override(new(dtypes.AfterGenesisSet), modules.SetGenesis),
|
||||||
|
Override(SetGenesisKey, modules.DoSetGenesis),
|
||||||
|
Override(new(beacon.Schedule), modules.RandomSchedule),
|
||||||
|
|
||||||
|
// Network bootstrap
|
||||||
Override(new(dtypes.BootstrapPeers), modules.BuiltinBootstrap),
|
Override(new(dtypes.BootstrapPeers), modules.BuiltinBootstrap),
|
||||||
Override(new(dtypes.DrandBootstrap), modules.DrandBootstrap),
|
Override(new(dtypes.DrandBootstrap), modules.DrandBootstrap),
|
||||||
Override(new(dtypes.DrandSchedule), modules.BuiltinDrandConfig),
|
|
||||||
|
|
||||||
|
// Consensus: crypto dependencies
|
||||||
Override(new(ffiwrapper.Verifier), ffiwrapper.ProofVerifier),
|
Override(new(ffiwrapper.Verifier), ffiwrapper.ProofVerifier),
|
||||||
|
|
||||||
|
// Consensus: VM
|
||||||
Override(new(vm.SyscallBuilder), vm.Syscalls),
|
Override(new(vm.SyscallBuilder), vm.Syscalls),
|
||||||
|
|
||||||
|
// Consensus: Chain storage/access
|
||||||
Override(new(*store.ChainStore), modules.ChainStore),
|
Override(new(*store.ChainStore), modules.ChainStore),
|
||||||
Override(new(stmgr.UpgradeSchedule), stmgr.DefaultUpgradeSchedule()),
|
|
||||||
Override(new(*stmgr.StateManager), modules.StateManager),
|
Override(new(*stmgr.StateManager), modules.StateManager),
|
||||||
Override(new(*wallet.LocalWallet), wallet.NewWallet),
|
|
||||||
Override(new(wallet.Default), From(new(*wallet.LocalWallet))),
|
|
||||||
Override(new(api.WalletAPI), From(new(wallet.MultiWallet))),
|
|
||||||
Override(new(*messagesigner.MessageSigner), messagesigner.NewMessageSigner),
|
|
||||||
|
|
||||||
Override(new(dtypes.ChainBitswap), modules.ChainBitswap),
|
Override(new(dtypes.ChainBitswap), modules.ChainBitswap),
|
||||||
Override(new(dtypes.ChainBlockService), modules.ChainBlockService),
|
Override(new(dtypes.ChainBlockService), modules.ChainBlockService), // todo: unused
|
||||||
|
|
||||||
|
// Consensus: Chain sync
|
||||||
|
|
||||||
// Filecoin services
|
|
||||||
// We don't want the SyncManagerCtor to be used as an fx constructor, but rather as a value.
|
// We don't want the SyncManagerCtor to be used as an fx constructor, but rather as a value.
|
||||||
// It will be called implicitly by the Syncer constructor.
|
// It will be called implicitly by the Syncer constructor.
|
||||||
Override(new(chain.SyncManagerCtor), func() chain.SyncManagerCtor { return chain.NewSyncManager }),
|
Override(new(chain.SyncManagerCtor), func() chain.SyncManagerCtor { return chain.NewSyncManager }),
|
||||||
Override(new(*chain.Syncer), modules.NewSyncer),
|
Override(new(*chain.Syncer), modules.NewSyncer),
|
||||||
Override(new(exchange.Client), exchange.NewClient),
|
Override(new(exchange.Client), exchange.NewClient),
|
||||||
Override(new(*messagepool.MessagePool), modules.MessagePool),
|
|
||||||
Override(new(dtypes.DefaultMaxFeeFunc), modules.NewDefaultMaxFeeFunc),
|
|
||||||
|
|
||||||
Override(new(modules.Genesis), modules.ErrorGenesis),
|
// Chain networking
|
||||||
Override(new(dtypes.AfterGenesisSet), modules.SetGenesis),
|
|
||||||
Override(SetGenesisKey, modules.DoSetGenesis),
|
|
||||||
|
|
||||||
Override(new(dtypes.NetworkName), modules.NetworkName),
|
|
||||||
Override(new(*hello.Service), hello.NewHelloService),
|
Override(new(*hello.Service), hello.NewHelloService),
|
||||||
Override(new(exchange.Server), exchange.NewServer),
|
Override(new(exchange.Server), exchange.NewServer),
|
||||||
Override(new(*peermgr.PeerMgr), peermgr.NewPeerMgr),
|
Override(new(*peermgr.PeerMgr), peermgr.NewPeerMgr),
|
||||||
|
|
||||||
Override(new(dtypes.Graphsync), modules.Graphsync(config.DefaultFullNode().Client.SimultaneousTransfers)),
|
// Chain mining API dependencies
|
||||||
|
Override(new(*slashfilter.SlashFilter), modules.NewSlashFilter),
|
||||||
|
|
||||||
|
// Service: Message Pool
|
||||||
|
Override(new(dtypes.DefaultMaxFeeFunc), modules.NewDefaultMaxFeeFunc),
|
||||||
|
Override(new(*messagepool.MessagePool), modules.MessagePool),
|
||||||
Override(new(*dtypes.MpoolLocker), new(dtypes.MpoolLocker)),
|
Override(new(*dtypes.MpoolLocker), new(dtypes.MpoolLocker)),
|
||||||
Override(new(*discoveryimpl.Local), modules.NewLocalDiscovery),
|
|
||||||
Override(new(discovery.PeerResolver), modules.RetrievalResolver),
|
|
||||||
|
|
||||||
Override(new(retrievalmarket.RetrievalClient), modules.RetrievalClient),
|
// Shared graphsync (markets, serving chain)
|
||||||
Override(new(dtypes.ClientDatastore), modules.NewClientDatastore),
|
Override(new(dtypes.Graphsync), modules.Graphsync(config.DefaultFullNode().Client.SimultaneousTransfers)),
|
||||||
Override(new(dtypes.ClientDataTransfer), modules.NewClientGraphsyncDataTransfer),
|
|
||||||
Override(new(storagemarket.StorageClient), modules.StorageClient),
|
|
||||||
Override(new(storagemarket.StorageClientNode), storageadapter.NewClientNodeAdapter),
|
|
||||||
Override(new(beacon.Schedule), modules.RandomSchedule),
|
|
||||||
|
|
||||||
|
// Service: Wallet
|
||||||
|
Override(new(*messagesigner.MessageSigner), messagesigner.NewMessageSigner),
|
||||||
|
Override(new(*wallet.LocalWallet), wallet.NewWallet),
|
||||||
|
Override(new(wallet.Default), From(new(*wallet.LocalWallet))),
|
||||||
|
Override(new(api.WalletAPI), From(new(wallet.MultiWallet))),
|
||||||
|
|
||||||
|
// Service: Payment channels
|
||||||
Override(new(*paychmgr.Store), paychmgr.NewStore),
|
Override(new(*paychmgr.Store), paychmgr.NewStore),
|
||||||
Override(new(*paychmgr.Manager), paychmgr.NewManager),
|
Override(new(*paychmgr.Manager), paychmgr.NewManager),
|
||||||
Override(new(*market.FundManager), market.NewFundManager),
|
|
||||||
Override(HandleMigrateClientFundsKey, modules.HandleMigrateClientFunds),
|
|
||||||
Override(HandlePaymentChannelManagerKey, paychmgr.HandleManager),
|
Override(HandlePaymentChannelManagerKey, paychmgr.HandleManager),
|
||||||
Override(SettlePaymentChannelsKey, settler.SettlePaymentChannels),
|
Override(SettlePaymentChannelsKey, settler.SettlePaymentChannels),
|
||||||
),
|
|
||||||
|
|
||||||
// Lite node
|
// Markets (common)
|
||||||
|
Override(new(*discoveryimpl.Local), modules.NewLocalDiscovery),
|
||||||
|
|
||||||
|
// Markets (retrieval)
|
||||||
|
Override(new(discovery.PeerResolver), modules.RetrievalResolver),
|
||||||
|
Override(new(retrievalmarket.RetrievalClient), modules.RetrievalClient),
|
||||||
|
Override(new(dtypes.ClientDataTransfer), modules.NewClientGraphsyncDataTransfer),
|
||||||
|
|
||||||
|
// Markets (storage)
|
||||||
|
Override(new(*market.FundManager), market.NewFundManager),
|
||||||
|
Override(new(dtypes.ClientDatastore), modules.NewClientDatastore),
|
||||||
|
Override(new(storagemarket.StorageClient), modules.StorageClient),
|
||||||
|
Override(new(storagemarket.StorageClientNode), storageadapter.NewClientNodeAdapter),
|
||||||
|
Override(HandleMigrateClientFundsKey, modules.HandleMigrateClientFunds),
|
||||||
|
|
||||||
|
// Lite node API
|
||||||
ApplyIf(isLiteNode,
|
ApplyIf(isLiteNode,
|
||||||
Override(new(messagesigner.MpoolNonceAPI), From(new(modules.MpoolNonceAPI))),
|
Override(new(messagesigner.MpoolNonceAPI), From(new(modules.MpoolNonceAPI))),
|
||||||
Override(new(full.ChainModuleAPI), From(new(api.GatewayAPI))),
|
Override(new(full.ChainModuleAPI), From(new(api.GatewayAPI))),
|
||||||
@ -326,7 +337,7 @@ func Online() Option {
|
|||||||
Override(new(stmgr.StateManagerAPI), modules.NewRPCStateManager),
|
Override(new(stmgr.StateManagerAPI), modules.NewRPCStateManager),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Full node
|
// Full node API / service startup
|
||||||
ApplyIf(isFullNode,
|
ApplyIf(isFullNode,
|
||||||
Override(new(messagesigner.MpoolNonceAPI), From(new(*messagepool.MessagePool))),
|
Override(new(messagesigner.MpoolNonceAPI), From(new(*messagepool.MessagePool))),
|
||||||
Override(new(full.ChainModuleAPI), From(new(full.ChainModule))),
|
Override(new(full.ChainModuleAPI), From(new(full.ChainModule))),
|
||||||
@ -341,51 +352,67 @@ func Online() Option {
|
|||||||
Override(HandleIncomingMessagesKey, modules.HandleIncomingMessages),
|
Override(HandleIncomingMessagesKey, modules.HandleIncomingMessages),
|
||||||
Override(HandleIncomingBlocksKey, modules.HandleIncomingBlocks),
|
Override(HandleIncomingBlocksKey, modules.HandleIncomingBlocks),
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
|
||||||
// miner
|
var MinerNode = Options(
|
||||||
ApplyIf(isType(repo.StorageMiner),
|
// API dependencies
|
||||||
Override(new(api.Common), From(new(common.CommonAPI))),
|
Override(new(api.Common), From(new(common.CommonAPI))),
|
||||||
Override(new(sectorstorage.StorageAuth), modules.StorageAuth),
|
Override(new(sectorstorage.StorageAuth), modules.StorageAuth),
|
||||||
|
|
||||||
Override(new(*stores.Index), stores.NewIndex),
|
// Actor config
|
||||||
Override(new(stores.SectorIndex), From(new(*stores.Index))),
|
|
||||||
Override(new(dtypes.MinerID), modules.MinerID),
|
|
||||||
Override(new(dtypes.MinerAddress), modules.MinerAddress),
|
Override(new(dtypes.MinerAddress), modules.MinerAddress),
|
||||||
|
Override(new(dtypes.MinerID), modules.MinerID),
|
||||||
Override(new(abi.RegisteredSealProof), modules.SealProofType),
|
Override(new(abi.RegisteredSealProof), modules.SealProofType),
|
||||||
Override(new(stores.LocalStorage), From(new(repo.LockedRepo))),
|
|
||||||
Override(new(sealing.SectorIDCounter), modules.SectorIDCounter),
|
|
||||||
Override(new(*sectorstorage.Manager), modules.SectorStorage),
|
|
||||||
Override(new(ffiwrapper.Verifier), ffiwrapper.ProofVerifier),
|
|
||||||
|
|
||||||
Override(new(sectorstorage.SectorManager), From(new(*sectorstorage.Manager))),
|
|
||||||
Override(new(storage2.Prover), From(new(sectorstorage.SectorManager))),
|
|
||||||
Override(new(storiface.WorkerReturn), From(new(sectorstorage.SectorManager))),
|
|
||||||
|
|
||||||
Override(new(*sectorblocks.SectorBlocks), sectorblocks.NewSectorBlocks),
|
|
||||||
Override(new(*storage.Miner), modules.StorageMiner(config.DefaultStorageMiner().Fees)),
|
|
||||||
Override(new(*storage.AddressSelector), modules.AddressSelector(nil)),
|
|
||||||
Override(new(dtypes.NetworkName), modules.StorageNetworkName),
|
Override(new(dtypes.NetworkName), modules.StorageNetworkName),
|
||||||
|
|
||||||
|
// Sector storage
|
||||||
|
Override(new(*stores.Index), stores.NewIndex),
|
||||||
|
Override(new(stores.SectorIndex), From(new(*stores.Index))),
|
||||||
|
Override(new(stores.LocalStorage), From(new(repo.LockedRepo))),
|
||||||
|
Override(new(*sectorstorage.Manager), modules.SectorStorage),
|
||||||
|
Override(new(sectorstorage.SectorManager), From(new(*sectorstorage.Manager))),
|
||||||
|
Override(new(storiface.WorkerReturn), From(new(sectorstorage.SectorManager))),
|
||||||
|
|
||||||
|
// Sector storage: Proofs
|
||||||
|
Override(new(ffiwrapper.Verifier), ffiwrapper.ProofVerifier),
|
||||||
|
Override(new(storage2.Prover), From(new(sectorstorage.SectorManager))),
|
||||||
|
|
||||||
|
// Sealing
|
||||||
|
Override(new(sealing.SectorIDCounter), modules.SectorIDCounter),
|
||||||
|
Override(GetParamsKey, modules.GetParams),
|
||||||
|
|
||||||
|
// Mining / proving
|
||||||
|
Override(new(*slashfilter.SlashFilter), modules.NewSlashFilter),
|
||||||
|
Override(new(*storage.Miner), modules.StorageMiner(config.DefaultStorageMiner().Fees)),
|
||||||
|
Override(new(*miner.Miner), modules.SetupBlockProducer),
|
||||||
|
Override(new(gen.WinningPoStProver), storage.NewWinningPoStProver),
|
||||||
|
|
||||||
|
Override(new(*storage.AddressSelector), modules.AddressSelector(nil)),
|
||||||
|
|
||||||
|
// Markets
|
||||||
Override(new(dtypes.StagingMultiDstore), modules.StagingMultiDatastore),
|
Override(new(dtypes.StagingMultiDstore), modules.StagingMultiDatastore),
|
||||||
Override(new(dtypes.StagingBlockstore), modules.StagingBlockstore),
|
Override(new(dtypes.StagingBlockstore), modules.StagingBlockstore),
|
||||||
Override(new(dtypes.StagingDAG), modules.StagingDAG),
|
Override(new(dtypes.StagingDAG), modules.StagingDAG),
|
||||||
Override(new(dtypes.StagingGraphsync), modules.StagingGraphsync),
|
Override(new(dtypes.StagingGraphsync), modules.StagingGraphsync),
|
||||||
Override(new(retrievalmarket.RetrievalProvider), modules.RetrievalProvider),
|
|
||||||
Override(new(dtypes.ProviderDataTransfer), modules.NewProviderDAGServiceDataTransfer),
|
|
||||||
Override(new(dtypes.ProviderPieceStore), modules.NewProviderPieceStore),
|
Override(new(dtypes.ProviderPieceStore), modules.NewProviderPieceStore),
|
||||||
|
Override(new(*sectorblocks.SectorBlocks), sectorblocks.NewSectorBlocks),
|
||||||
|
|
||||||
|
// Markets (retrieval)
|
||||||
|
Override(new(retrievalmarket.RetrievalProvider), modules.RetrievalProvider),
|
||||||
|
Override(new(dtypes.RetrievalDealFilter), modules.RetrievalDealFilter(nil)),
|
||||||
|
Override(HandleRetrievalKey, modules.HandleRetrieval),
|
||||||
|
|
||||||
|
// Markets (storage)
|
||||||
|
Override(new(dtypes.ProviderDataTransfer), modules.NewProviderDAGServiceDataTransfer),
|
||||||
Override(new(*storedask.StoredAsk), modules.NewStorageAsk),
|
Override(new(*storedask.StoredAsk), modules.NewStorageAsk),
|
||||||
Override(new(dtypes.StorageDealFilter), modules.BasicDealFilter(nil)),
|
Override(new(dtypes.StorageDealFilter), modules.BasicDealFilter(nil)),
|
||||||
Override(new(dtypes.RetrievalDealFilter), modules.RetrievalDealFilter(nil)),
|
|
||||||
Override(new(storagemarket.StorageProvider), modules.StorageProvider),
|
Override(new(storagemarket.StorageProvider), modules.StorageProvider),
|
||||||
Override(new(*storageadapter.DealPublisher), storageadapter.NewDealPublisher(nil, storageadapter.PublishMsgConfig{})),
|
Override(new(*storageadapter.DealPublisher), storageadapter.NewDealPublisher(nil, storageadapter.PublishMsgConfig{})),
|
||||||
Override(new(storagemarket.StorageProviderNode), storageadapter.NewProviderNodeAdapter(nil)),
|
Override(new(storagemarket.StorageProviderNode), storageadapter.NewProviderNodeAdapter(nil)),
|
||||||
Override(HandleMigrateProviderFundsKey, modules.HandleMigrateProviderFunds),
|
Override(HandleMigrateProviderFundsKey, modules.HandleMigrateProviderFunds),
|
||||||
Override(HandleRetrievalKey, modules.HandleRetrieval),
|
|
||||||
Override(GetParamsKey, modules.GetParams),
|
|
||||||
Override(HandleDealsKey, modules.HandleDeals),
|
Override(HandleDealsKey, modules.HandleDeals),
|
||||||
Override(new(gen.WinningPoStProver), storage.NewWinningPoStProver),
|
|
||||||
Override(new(*miner.Miner), modules.SetupBlockProducer),
|
|
||||||
|
|
||||||
|
// Config (todo: get a real property system)
|
||||||
Override(new(dtypes.ConsiderOnlineStorageDealsConfigFunc), modules.NewConsiderOnlineStorageDealsConfigFunc),
|
Override(new(dtypes.ConsiderOnlineStorageDealsConfigFunc), modules.NewConsiderOnlineStorageDealsConfigFunc),
|
||||||
Override(new(dtypes.SetConsiderOnlineStorageDealsConfigFunc), modules.NewSetConsideringOnlineStorageDealsFunc),
|
Override(new(dtypes.SetConsiderOnlineStorageDealsConfigFunc), modules.NewSetConsideringOnlineStorageDealsFunc),
|
||||||
Override(new(dtypes.ConsiderOnlineRetrievalDealsConfigFunc), modules.NewConsiderOnlineRetrievalDealsConfigFunc),
|
Override(new(dtypes.ConsiderOnlineRetrievalDealsConfigFunc), modules.NewConsiderOnlineRetrievalDealsConfigFunc),
|
||||||
@ -404,7 +431,23 @@ func Online() Option {
|
|||||||
Override(new(dtypes.GetSealingConfigFunc), modules.NewGetSealConfigFunc),
|
Override(new(dtypes.GetSealingConfigFunc), modules.NewGetSealConfigFunc),
|
||||||
Override(new(dtypes.SetExpectedSealDurationFunc), modules.NewSetExpectedSealDurationFunc),
|
Override(new(dtypes.SetExpectedSealDurationFunc), modules.NewSetExpectedSealDurationFunc),
|
||||||
Override(new(dtypes.GetExpectedSealDurationFunc), modules.NewGetExpectedSealDurationFunc),
|
Override(new(dtypes.GetExpectedSealDurationFunc), modules.NewGetExpectedSealDurationFunc),
|
||||||
|
)
|
||||||
|
|
||||||
|
// Online sets up basic libp2p node
|
||||||
|
func Online() Option {
|
||||||
|
|
||||||
|
return Options(
|
||||||
|
// make sure that online is applied before Config.
|
||||||
|
// This is important because Config overrides some of Online units
|
||||||
|
func(s *Settings) error { s.Online = true; return nil },
|
||||||
|
ApplyIf(func(s *Settings) bool { return s.Config },
|
||||||
|
Error(errors.New("the Online option must be set before Config option")),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
LibP2P,
|
||||||
|
|
||||||
|
ApplyIf(isFullOrLiteNode, ChainNode),
|
||||||
|
ApplyIf(isType(repo.StorageMiner), MinerNode),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user