MCPcopy
hub / github.com/ipfs/kubo / IPFS

Function IPFS

core/node/groups.go:405–468  ·  view source on GitHub ↗

IPFS builds a group of fx Options based on the passed BuildCfg

(ctx context.Context, bcfg *BuildCfg)

Source from the content-addressed store, hash-verified

403
404// IPFS builds a group of fx Options based on the passed BuildCfg
405func IPFS(ctx context.Context, bcfg *BuildCfg) fx.Option {
406 if bcfg == nil {
407 bcfg = new(BuildCfg)
408 }
409
410 bcfgOpts, cfg := bcfg.options(ctx)
411 if cfg == nil {
412 return bcfgOpts // error
413 }
414
415 userResourceOverrides, err := bcfg.Repo.UserResourceOverrides()
416 if err != nil {
417 return fx.Error(err)
418 }
419
420 // Migrate users of deprecated Experimental.ShardingEnabled flag
421 if cfg.Experimental.ShardingEnabled {
422 logger.Fatal("The `Experimental.ShardingEnabled` field is no longer used, please remove it from the config. Use Import.UnixFSHAMTDirectorySizeThreshold instead.")
423 }
424 if !cfg.Internal.UnixFSShardingSizeThreshold.IsDefault() {
425 msg := "The `Internal.UnixFSShardingSizeThreshold` field was renamed to `Import.UnixFSHAMTDirectorySizeThreshold`. Please update your config.\n"
426 if !cfg.Import.UnixFSHAMTDirectorySizeThreshold.IsDefault() {
427 logger.Fatal(msg) // conflicting values, hard fail
428 }
429 logger.Error(msg)
430 // Migrate the old OptionalString value to the new OptionalBytes field.
431 // Since OptionalBytes embeds OptionalString, we can construct it directly
432 // with the old value, preserving the user's original string (e.g., "256KiB").
433 cfg.Import.UnixFSHAMTDirectorySizeThreshold = config.OptionalBytes{OptionalString: *cfg.Internal.UnixFSShardingSizeThreshold}
434 }
435
436 // Validate Import configuration
437 if err := config.ValidateImportConfig(&cfg.Import); err != nil {
438 return fx.Error(err)
439 }
440
441 // Validate Provide configuration
442 if err := config.ValidateProvideConfig(&cfg.Provide); err != nil {
443 return fx.Error(err)
444 }
445
446 // Directory sharding settings from Import config.
447 // These globals affect both `ipfs add` and MFS (`ipfs files` API).
448 shardSizeThreshold := cfg.Import.UnixFSHAMTDirectorySizeThreshold.WithDefault(config.DefaultUnixFSHAMTDirectorySizeThreshold)
449 shardMaxFanout := cfg.Import.UnixFSHAMTDirectoryMaxFanout.WithDefault(config.DefaultUnixFSHAMTDirectoryMaxFanout)
450 uio.HAMTShardingSize = int(shardSizeThreshold)
451 uio.DefaultShardWidth = int(shardMaxFanout)
452 uio.HAMTSizeEstimation = cfg.Import.HAMTSizeEstimationMode()
453
454 providerStrategy := cfg.Provide.Strategy.WithDefault(config.DefaultProvideStrategy)
455
456 return fx.Options(
457 bcfgOpts,
458
459 Storage(bcfg, cfg),
460 Identity(cfg),
461 IPNS,
462 Networked(bcfg, cfg, userResourceOverrides),

Callers 1

NewNodeFunction · 0.92

Calls 15

ValidateImportConfigFunction · 0.92
ValidateProvideConfigFunction · 0.92
StorageFunction · 0.85
NetworkedFunction · 0.85
BlockServiceFunction · 0.85
FilesFunction · 0.85
optionsMethod · 0.80
FatalMethod · 0.80
IdentityFunction · 0.70
PinningFunction · 0.70
UserResourceOverridesMethod · 0.65

Tested by

no test coverage detected