node

package
v1.10.0-binaries Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2021 License: Apache-2.0, MIT Imports: 74 Imported by: 16

Documentation

Index

Constants

View Source
const (
	// InitJournal at position 0 initializes the journal global var as soon as
	// the system starts, so that it's available for all other components.
	InitJournalKey = invoke(iota)

	// System processes.
	InitMemoryWatchdog

	// libp2p
	PstoreAddSelfKeysKey
	StartListeningKey
	BootstrapKey

	// filecoin
	SetGenesisKey

	RunHelloKey
	RunChainExchangeKey
	RunChainGraphsync
	RunPeerMgrKey

	HandleIncomingBlocksKey
	HandleIncomingMessagesKey
	HandleMigrateClientFundsKey
	HandlePaymentChannelManagerKey

	// miner
	GetParamsKey
	HandleMigrateProviderFundsKey
	HandleDealsKey
	HandleRetrievalKey
	RunSectorServiceKey

	// daemon
	ExtractApiKey
	HeadMetricsKey
	SettlePaymentChannelsKey
	RunPeerTaggerKey
	SetupFallbackBlockstoresKey

	SetApiEndpointKey
)

Invokes are called in the order they are defined.

Variables

View Source
var (
	DefaultTransportsKey = special{0}  // Libp2p option
	DiscoveryHandlerKey  = special{2}  // Private type
	AddrsFactoryKey      = special{3}  // Libp2p option
	SmuxTransportKey     = special{4}  // Libp2p option
	RelayKey             = special{5}  // Libp2p option
	SecurityKey          = special{6}  // Libp2p option
	BaseRoutingKey       = special{7}  // fx groups + multiret
	NatPortMapKey        = special{8}  // Libp2p option
	ConnectionManagerKey = special{9}  // Libp2p option
	AutoNATSvcKey        = special{10} // Libp2p option
	BandwidthReporterKey = special{11} // Libp2p option
	ConnGaterKey         = special{12} // libp2p option
)
View Source
var ChainNode = Options(

	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),

	Override(new(dtypes.BootstrapPeers), modules.BuiltinBootstrap),
	Override(new(dtypes.DrandBootstrap), modules.DrandBootstrap),

	Override(new(ffiwrapper.Verifier), ffiwrapper.ProofVerifier),

	Override(new(vm.SyscallBuilder), vm.Syscalls),

	Override(new(*store.ChainStore), modules.ChainStore),
	Override(new(*stmgr.StateManager), modules.StateManager),
	Override(new(dtypes.ChainBitswap), modules.ChainBitswap),
	Override(new(dtypes.ChainBlockService), modules.ChainBlockService),

	Override(new(chain.SyncManagerCtor), func() chain.SyncManagerCtor { return chain.NewSyncManager }),
	Override(new(*chain.Syncer), modules.NewSyncer),
	Override(new(exchange.Client), exchange.NewClient),

	Override(new(*hello.Service), hello.NewHelloService),
	Override(new(exchange.Server), exchange.NewServer),
	Override(new(*peermgr.PeerMgr), peermgr.NewPeerMgr),

	Override(new(*slashfilter.SlashFilter), modules.NewSlashFilter),

	Override(new(dtypes.DefaultMaxFeeFunc), modules.NewDefaultMaxFeeFunc),
	Override(new(*messagepool.MessagePool), modules.MessagePool),
	Override(new(*dtypes.MpoolLocker), new(dtypes.MpoolLocker)),

	Override(new(dtypes.Graphsync), modules.Graphsync(config.DefaultFullNode().Client.SimultaneousTransfers)),

	Override(new(*messagesigner.MessageSigner), messagesigner.NewMessageSigner),
	Override(new(*wallet.LocalWallet), wallet.NewWallet),
	Override(new(wallet.Default), From(new(*wallet.LocalWallet))),
	Override(new(api.Wallet), From(new(wallet.MultiWallet))),

	Override(new(paychmgr.PaychAPI), From(new(modules.PaychAPI))),
	Override(new(*paychmgr.Store), modules.NewPaychStore),
	Override(new(*paychmgr.Manager), modules.NewManager),
	Override(HandlePaymentChannelManagerKey, modules.HandlePaychManager),
	Override(SettlePaymentChannelsKey, settler.SettlePaymentChannels),

	Override(new(*discoveryimpl.Local), modules.NewLocalDiscovery),

	Override(new(discovery.PeerResolver), modules.RetrievalResolver),
	Override(new(retrievalmarket.RetrievalClient), modules.RetrievalClient),
	Override(new(dtypes.ClientDataTransfer), modules.NewClientGraphsyncDataTransfer),

	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),

	Override(new(*full.GasPriceCache), full.NewGasPriceCache),

	ApplyIf(isLiteNode,
		Override(new(messagesigner.MpoolNonceAPI), From(new(modules.MpoolNonceAPI))),
		Override(new(full.ChainModuleAPI), From(new(api.Gateway))),
		Override(new(full.GasModuleAPI), From(new(api.Gateway))),
		Override(new(full.MpoolModuleAPI), From(new(api.Gateway))),
		Override(new(full.StateModuleAPI), From(new(api.Gateway))),
		Override(new(stmgr.StateManagerAPI), rpcstmgr.NewRPCStateManager),
	),

	ApplyIf(isFullNode,
		Override(new(messagesigner.MpoolNonceAPI), From(new(*messagepool.MessagePool))),
		Override(new(full.ChainModuleAPI), From(new(full.ChainModule))),
		Override(new(full.GasModuleAPI), From(new(full.GasModule))),
		Override(new(full.MpoolModuleAPI), From(new(full.MpoolModule))),
		Override(new(full.StateModuleAPI), From(new(full.StateModule))),
		Override(new(stmgr.StateManagerAPI), From(new(*stmgr.StateManager))),

		Override(RunHelloKey, modules.RunHello),
		Override(RunChainExchangeKey, modules.RunChainExchange),
		Override(RunPeerMgrKey, modules.RunPeerMgr),
		Override(HandleIncomingMessagesKey, modules.HandleIncomingMessages),
		Override(HandleIncomingBlocksKey, modules.HandleIncomingBlocks),
	),
)

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)

View Source
var MinerNode = Options(

	Override(new(api.Common), From(new(common.CommonAPI))),
	Override(new(sectorstorage.StorageAuth), modules.StorageAuth),

	Override(new(dtypes.MinerAddress), modules.MinerAddress),
	Override(new(dtypes.MinerID), modules.MinerID),
	Override(new(abi.RegisteredSealProof), modules.SealProofType),
	Override(new(dtypes.NetworkName), modules.StorageNetworkName),

	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))),

	Override(new(ffiwrapper.Verifier), ffiwrapper.ProofVerifier),
	Override(new(ffiwrapper.Prover), ffiwrapper.ProofProver),
	Override(new(storage2.Prover), From(new(sectorstorage.SectorManager))),

	Override(new(sealing.SectorIDCounter), modules.SectorIDCounter),
	Override(GetParamsKey, modules.GetParams),

	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)),

	Override(new(dtypes.StagingMultiDstore), modules.StagingMultiDatastore),
	Override(new(dtypes.StagingBlockstore), modules.StagingBlockstore),
	Override(new(dtypes.StagingDAG), modules.StagingDAG),
	Override(new(dtypes.StagingGraphsync), modules.StagingGraphsync),
	Override(new(dtypes.ProviderPieceStore), modules.NewProviderPieceStore),
	Override(new(*sectorblocks.SectorBlocks), sectorblocks.NewSectorBlocks),

	Override(new(retrievalmarket.RetrievalProvider), modules.RetrievalProvider),
	Override(new(dtypes.RetrievalDealFilter), modules.RetrievalDealFilter(nil)),
	Override(HandleRetrievalKey, modules.HandleRetrieval),

	Override(new(dtypes.ProviderDataTransfer), modules.NewProviderDAGServiceDataTransfer),
	Override(new(*storedask.StoredAsk), modules.NewStorageAsk),
	Override(new(dtypes.StorageDealFilter), modules.BasicDealFilter(nil)),
	Override(new(storagemarket.StorageProvider), modules.StorageProvider),
	Override(new(*storageadapter.DealPublisher), storageadapter.NewDealPublisher(nil, storageadapter.PublishMsgConfig{})),
	Override(new(storagemarket.StorageProviderNode), storageadapter.NewProviderNodeAdapter(nil, nil)),
	Override(HandleMigrateProviderFundsKey, modules.HandleMigrateProviderFunds),
	Override(HandleDealsKey, modules.HandleDeals),

	Override(new(dtypes.ConsiderOnlineStorageDealsConfigFunc), modules.NewConsiderOnlineStorageDealsConfigFunc),
	Override(new(dtypes.SetConsiderOnlineStorageDealsConfigFunc), modules.NewSetConsideringOnlineStorageDealsFunc),
	Override(new(dtypes.ConsiderOnlineRetrievalDealsConfigFunc), modules.NewConsiderOnlineRetrievalDealsConfigFunc),
	Override(new(dtypes.SetConsiderOnlineRetrievalDealsConfigFunc), modules.NewSetConsiderOnlineRetrievalDealsConfigFunc),
	Override(new(dtypes.StorageDealPieceCidBlocklistConfigFunc), modules.NewStorageDealPieceCidBlocklistConfigFunc),
	Override(new(dtypes.SetStorageDealPieceCidBlocklistConfigFunc), modules.NewSetStorageDealPieceCidBlocklistConfigFunc),
	Override(new(dtypes.ConsiderOfflineStorageDealsConfigFunc), modules.NewConsiderOfflineStorageDealsConfigFunc),
	Override(new(dtypes.SetConsiderOfflineStorageDealsConfigFunc), modules.NewSetConsideringOfflineStorageDealsFunc),
	Override(new(dtypes.ConsiderOfflineRetrievalDealsConfigFunc), modules.NewConsiderOfflineRetrievalDealsConfigFunc),
	Override(new(dtypes.SetConsiderOfflineRetrievalDealsConfigFunc), modules.NewSetConsiderOfflineRetrievalDealsConfigFunc),
	Override(new(dtypes.ConsiderVerifiedStorageDealsConfigFunc), modules.NewConsiderVerifiedStorageDealsConfigFunc),
	Override(new(dtypes.SetConsiderVerifiedStorageDealsConfigFunc), modules.NewSetConsideringVerifiedStorageDealsFunc),
	Override(new(dtypes.ConsiderUnverifiedStorageDealsConfigFunc), modules.NewConsiderUnverifiedStorageDealsConfigFunc),
	Override(new(dtypes.SetConsiderUnverifiedStorageDealsConfigFunc), modules.NewSetConsideringUnverifiedStorageDealsFunc),
	Override(new(dtypes.SetSealingConfigFunc), modules.NewSetSealConfigFunc),
	Override(new(dtypes.GetSealingConfigFunc), modules.NewGetSealConfigFunc),
	Override(new(dtypes.SetExpectedSealDurationFunc), modules.NewSetExpectedSealDurationFunc),
	Override(new(dtypes.GetExpectedSealDurationFunc), modules.NewGetExpectedSealDurationFunc),
	Override(new(dtypes.SetMaxDealStartDelayFunc), modules.NewSetMaxDealStartDelayFunc),
	Override(new(dtypes.GetMaxDealStartDelayFunc), modules.NewGetMaxDealStartDelayFunc),
)

Functions

func From added in v0.3.0

func From(typ interface{}) interface{}

From(*T) -> func(t T) T {return t}

func WithInvokesKey added in v1.9.0

func WithInvokesKey(i invoke, resApi interface{}) func(s *Settings) error

func WithRepoType added in v1.9.0

func WithRepoType(repoType repo.RepoType) func(s *Settings) error

Types

type FullOption added in v0.9.1

type FullOption = Option

func Lite added in v0.9.1

func Lite(enable bool) FullOption

type Option

type Option func(*Settings) error

Option is a functional option which can be used with the New function to change how the node is constructed

Options are applied in sequence

func ApplyIf

func ApplyIf(check func(s *Settings) bool, opts ...Option) Option

func ConfigCommon

func ConfigCommon(cfg *config.Common) Option

Config sets up constructors based on the provided Config

func ConfigFullNode

func ConfigFullNode(c interface{}) Option

func ConfigStorageMiner

func ConfigStorageMiner(c interface{}) Option

func Error

func Error(err error) Option

Error is a special option which returns an error when applied

func FullAPI

func FullAPI(out *api.FullNode, fopts ...FullOption) Option

func If

func If(b bool, opts ...Option) Option

func MockHost

func MockHost(mn mocknet.Mocknet) Option

func Online

func Online() Option

Online sets up basic libp2p node

func Options

func Options(opts ...Option) Option

Options groups multiple options into one

func Override

func Override(typ, constructor interface{}) Option

Override option changes constructor for a given type

func Repo

func Repo(r repo.Repo) Option

func StorageMiner

func StorageMiner(out *api.StorageMiner) Option

func Test

func Test() Option

func Unset

func Unset(typ interface{}) Option

type Settings

type Settings struct {
	Online bool // Online option applied
	Config bool // Config option applied
	Lite   bool // Start node in "lite" mode
	// contains filtered or unexported fields
}

type StopFunc

type StopFunc func(context.Context) error

func New

func New(ctx context.Context, opts ...Option) (StopFunc, error)

New builds and starts new Filecoin node

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL