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 = const NetworkConfig(), DHTConfig dht = const DHTConfig(), StorageConfig storage = const StorageConfig(), SecurityConfig security = const SecurityConfig(), bool debug = true, bool verboseLogging = true, bool enablePubSub = true, bool enableDHT = true, bool enableCircuitRelay = true, bool enableContentRouting = true, bool enableDNSLinkResolution = true, bool enableIPLD = true, bool enableGraphsync = true, bool enableMetrics = true, bool enableLogging = true, String logLevel = 'info', bool enableQuotaManagement = true, int defaultBandwidthQuota = 1048576, String datastorePath = './ipfs_data', String keystorePath = './ipfs_keystore', String blockStorePath = 'blocks', String? nodeId, Duration garbageCollectionInterval = const Duration(hours: 24), bool garbageCollectionEnabled = true, MetricsConfig metrics = const MetricsConfig(), String dataPath = './ipfs_data', Keystore? keystore, Map<String, dynamic> customConfig = const {}})
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

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
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
garbageCollectionEnabled bool
Enable automatic garbage collection.
final
garbageCollectionInterval Duration
Interval for garbage collection.
final
hashCode int
The hash code for this object.
no setterinherited
keystore → Keystore
The keystore for managing keys.
final
keystorePath String
Path to the keystore.
final
logLevel String
The logging level (e.g., 'info', 'debug', 'error').
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
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
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 YAML file