IPFSConfig class

Configuration for an IPFS node.

This class defines all configuration options for initializing and running an IPFS node, including storage paths, networking parameters, security settings, and service configurations.

Basic Configuration:

final config = IPFSConfig(
  offline: false,  // Enable P2P networking
  blockStorePath: './ipfs/blocks',
  datastorePath: './ipfs/datastore',
);

Advanced Configuration:

final config = IPFSConfig(
  offline: false,
  network: NetworkConfig(
    bootstrapPeers: ['<multiaddr>', ...],
    listenAddresses: ['/ip4/0.0.0.0/tcp/4001'],
  ),
  dht: DHTConfig(
    mode: DHTMode.server,  // Participate as DHT server
    bucketSize: 20,
  ),
  security: SecurityConfig(
    enableEncryption: true,
  ),
);

Deployment Modes:

Offline Mode (Local storage only):

IPFSConfig(offline: true)

Gateway Mode (HTTP serving):

IPFSConfig(
  offline: true,
  gateway: GatewayConfig(enabled: true, port: 8080),
)

Full P2P Mode (Network participation):

IPFSConfig(offline: false)

Constructors

IPFSConfig({bool offline = false, NetworkConfig? network, DHTConfig? dht, @Deprecated('StorageConfig is never read; use the top-level path fields.') StorageConfig? storage, SecurityConfig? security, GatewayConfig? gateway, BitswapConfig? bitswap, GraphsyncConfig? graphsync, bool debug = true, bool verboseLogging = true, bool enablePubSub = true, bool enableDHT = true, bool enableRPC = false, String? rpcApiKey, @Deprecated('Use NetworkConfig.circuitRelay.enabled; this option is ignored.') bool enableCircuitRelay = true, bool enableContentRouting = true, bool enableDNSLinkResolution = true, @Deprecated('IPLD is a core dependency and cannot be disabled; this flag is ignored.') bool enableIPLD = true, bool enableGraphsync = true, bool enableMetrics = true, bool enableIpnsPubSub = false, @Deprecated('Logging is always enabled; use logLevel to control verbosity.') bool enableLogging = true, @Deprecated('Structured logging is not wired into the node runtime; ' 'this option is ignored.') bool enableStructuredLogging = false, int ipnsCacheSize = 1000, String logLevel = 'info', @Deprecated('No bandwidth quota subsystem exists; this flag is ignored.') bool enableQuotaManagement = true, @Deprecated('No bandwidth quota subsystem exists; this flag is ignored.') int defaultBandwidthQuota = 1048576, int maxConcurrentBitswapRequests = 10, String datastorePath = './ipfs_data/datastore', String keystorePath = './ipfs_keystore', String blockStorePath = 'blocks', @Deprecated('No libp2p bridge transport exists; this flag is ignored.') bool enableLibp2pBridge = false, String libp2pListenAddress = '/ip4/0.0.0.0/tcp/4001', Uint8List? libp2pIdentitySeed, String? nodeId, @Deprecated('No repository garbage-collection loop exists; this flag is ignored.') Duration garbageCollectionInterval = const Duration(hours: 24), @Deprecated('No repository garbage-collection loop exists; this flag is ignored.') bool garbageCollectionEnabled = true, MetricsConfig metrics = const MetricsConfig(), String dataPath = './ipfs_data', Keystore? keystore, @Deprecated('Use GraphsyncConfig.defaultMaxDepth; this flag is ignored.') int maxSelectorDepth = 32, @Deprecated('Use GraphsyncConfig.defaultMaxBlocks; this flag is ignored.') int maxSelectorNodes = 10000, @Deprecated('Custom config entries are never read; this option is ignored.') Map<String, dynamic> customConfig = const {}, String? swarmKeyPath, Uint8List? privateNetworkPsk})
Creates a new IPFSConfig with the specified options.
IPFSConfig.fromJson(Map<String, dynamic> json)
Creates configuration from JSON
factory
IPFSConfig.withDefaults()
Creates a new IPFSConfig with a generated nodeId
factory

Properties

bitswap → BitswapConfig
Bitswap protocol configuration.
final
blockStorePath → String
Path to the blockstore.
final
customConfig → Map<String, dynamic>
Key-value pair for custom configuration options.
final
dataPath → String
The base path for node data.
final
datastorePath → String
Path to the datastore.
final
debug → bool
Enable debug mode.
final
defaultBandwidthQuota → int
Default bandwidth quota in bytes.
final
dht → DHTConfig
Distributed Hash Table configuration.
final
enableCircuitRelay → bool
Enable Circuit Relay support.
final
enableContentRouting → bool
Enable content routing.
final
enableDHT → bool
Enable DHT protocols.
final
enableDNSLinkResolution → bool
Enable DNSLink resolution.
final
enableGraphsync → bool
Enable Graphsync protocol.
final
enableIPLD → bool
Enable IPLD support.
final
enableIpnsPubSub → bool
Enable IPNS PubSub notifications.
final
enableLibp2pBridge → bool
Whether to enable the libp2p bridge transport.
final
enableLogging → bool
Enable system-wide logging.
final
enableMetrics → bool
Enable metrics collection.
final
enablePubSub → bool
Enable PubSub protocols.
final
enableQuotaManagement → bool
Enable bandwidth quota management.
final
enableRPC → bool
Enable the RPC API server.
final
enableStructuredLogging → bool
Enable structured (JSON) logging.
final
garbageCollectionEnabled → bool
Enable automatic garbage collection.
final
garbageCollectionInterval → Duration
Interval for garbage collection.
final
gateway → GatewayConfig
HTTP Gateway configuration.
final
graphsync → GraphsyncConfig
Graphsync protocol configuration.
final
hashCode → int
The hash code for this object.
no setterinherited
ipnsCacheSize → int
The size of the IPNS resolution cache.
final
keystore → Keystore
The keystore for managing keys.
final
keystorePath → String
Path to the keystore.
final
libp2pIdentitySeed → Uint8List?
Optional seed for persistent libp2p identity.
final
libp2pListenAddress → String
Legacy single listen address for the libp2p host.
final
logLevel → String
The logging level (e.g., 'info', 'debug', 'error').
final
maxConcurrentBitswapRequests → int
Maximum concurrent bitswap requests.
final
maxSelectorDepth → int
Maximum recursion depth for IPLD selector execution.
final
maxSelectorNodes → int
Maximum number of nodes to visit during IPLD selector execution.
final
metrics → MetricsConfig
Metrics collection configuration.
final
network → NetworkConfig
Detailed network configuration.
final
nodeId → String
The unique node identifier.
final
offline → bool
Run node in offline mode.
final
privateNetworkPsk → Uint8List?
The 32-byte pre-shared key loaded from swarmKeyPath.
final
rpcApiKey → String?
Optional API key required by the RPC server for protected endpoints.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
security → SecurityConfig
Security and identity configuration.
final
storage → StorageConfig
Storage and datastore configuration.
final
swarmKeyPath → String?
Optional path to a libp2p private-network swarm key file.
final
verboseLogging → bool
Enable verbose logging.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, dynamic>
Converts to JSON representation.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

fromFile(String path) → Future<IPFSConfig>
Loads configuration from a JSON or YAML file.