node

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: Apache-2.0, MIT Imports: 94 Imported by: 2

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

	// health checks
	CheckFDLimit

	// libp2p
	PstoreAddSelfKeysKey
	StartListeningKey
	BootstrapKey

	// filecoin
	SetGenesisKey

	RunHelloKey
	RunChainExchangeKey
	RunChainGraphsync
	RunPeerMgrKey

	HandleIncomingBlocksKey
	HandleIncomingMessagesKey
	HandleMigrateClientFundsKey
	HandlePaymentChannelManagerKey

	// miner
	GetParamsKey
	HandleMigrateProviderFundsKey
	HandleDealsKey
	HandleCreateRetrievalTablesKey
	HandleSetShardSelector
	HandleSetRetrievalAskGetter
	HandleRetrievalEventsKey
	HandleRetrievalKey
	HandleRetrievalTransportsKey
	HandleProtocolProxyKey
	RunSectorServiceKey

	// boost should be started after legacy markets (HandleDealsKey)
	HandleBoostDealsKey
	HandleContractDealsKey
	HandleProposalLogCleanerKey
	HandleOnlineBackupMgrKey

	// daemon
	ExtractApiKey
	HeadMetricsKey
	SettlePaymentChannelsKey
	RunPeerTaggerKey
	SetupFallbackBlockstoresKey
	HandleSetLinkSystem

	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
	DAGStoreKey          = special{13} // constructor returns multiple values
	ResourceManagerKey   = special{14} // Libp2p option
	UserAgentKey         = special{15} // Libp2p option
)
View Source
var LibP2P = Options(

	Override(new(lotus_dtypes.Bootstrapper), lotus_dtypes.Bootstrapper(false)),

	Override(new(peerstore.Peerstore), func() (peerstore.Peerstore, error) { return pstoremem.NewPeerstore() }),
	Override(PstoreAddSelfKeysKey, lotus_lp2p.PstoreAddSelfKeys),
	Override(StartListeningKey, lotus_lp2p.StartListening([]string{"/ip4/127.0.0.1/tcp/1899"})),

	Override(DefaultTransportsKey, lotus_lp2p.DefaultTransports),
	Override(AddrsFactoryKey, lotus_lp2p.AddrsFactory(nil, nil)),
	Override(SmuxTransportKey, lotus_lp2p.SmuxTransport()),
	Override(RelayKey, lotus_lp2p.NoRelay()),
	Override(SecurityKey, lotus_lp2p.Security(true, false)),
	Override(DefaultTransportsKey, lp2p.DefaultTransports),
	Override(UserAgentKey, modules.UserAgent),

	Override(new(lotus_lp2p.RawHost), lotus_lp2p.Host),
	Override(new(host.Host), lotus_lp2p.RoutedHost),
	Override(new(lotus_lp2p.BaseIpfsRouting), lotus_lp2p.DHTRouting(dht.ModeAuto)),

	Override(DiscoveryHandlerKey, lotus_lp2p.DiscoveryHandler),

	Override(new(record.Validator), modules.RecordValidator),
	Override(BaseRoutingKey, lotus_lp2p.BaseRouting),
	Override(new(routing.Routing), lotus_lp2p.Routing),

	Override(BandwidthReporterKey, lotus_lp2p.BandwidthCounter),
	Override(AutoNATSvcKey, lotus_lp2p.AutoNATService),

	Override(new(*lotus_dtypes.ScoreKeeper), lotus_lp2p.ScoreKeeper),
	Override(new(*pubsub.PubSub), lotus_lp2p.GossipSub),
	Override(new(*lotus_config.Pubsub), func(bs lotus_dtypes.Bootstrapper) *lotus_config.Pubsub {
		return &lotus_config.Pubsub{
			Bootstrapper: bool(bs),
		}
	}),

	Override(ConnectionManagerKey, lotus_lp2p.ConnectionManager(50, 200, 20*time.Second, nil)),
	Override(new(*conngater.BasicConnectionGater), lotus_lp2p.ConnGater),
	Override(ConnGaterKey, lotus_lp2p.ConnGaterOption),
)

Functions

func BoostHandler

func BoostHandler(a api.Boost, permissioned bool) (http.Handler, error)

BoostHandler returns a boost service handler, to be mounted as-is on the server.

func From

func From(typ interface{}) interface{}

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

func FromVal added in v1.6.0

func FromVal[T any](v T) func() T

func MonitorShutdown

func MonitorShutdown(triggerCh <-chan struct{}, handlers ...ShutdownHandler) <-chan struct{}

MonitorShutdown manages shutdown requests, by watching signals and invoking the supplied handlers in order.

It watches SIGTERM and SIGINT OS signals, as well as the trigger channel. When any of them fire, it calls the supplied handlers in order. If any of them errors, it merely logs the error.

Once the shutdown has completed, it closes the returned channel. The caller can watch this channel

Types

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 Base

func Base() Option

func BoostAPI

func BoostAPI(out *api.Boost) Option

func ConfigBoost

func ConfigBoost(cfg *config.Boost) Option

func ConfigCommon

func ConfigCommon(cfg *config.Common) Option

Config sets up constructors based on the provided Config

func Error

func Error(err error) Option

Error is a special option which returns an error when applied

func If

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

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 lotus_repo.Repo) Option

func Unset

func Unset(typ interface{}) Option

type Settings

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

type ShutdownHandler

type ShutdownHandler struct {
	Component string
	StopFunc  StopFunc
}

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

func ServeRPC

func ServeRPC(h http.Handler, id string, addr multiaddr.Multiaddr) (StopFunc, error)

ServeRPC serves an HTTP handler over the supplied listen multiaddr.

This function spawns a goroutine to run the server, and returns immediately. It returns the stop function to be called to terminate the endpoint.

The supplied ID is used in tracing, by inserting a tag in the context.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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