IPFSConfig.fromJson constructor

IPFSConfig.fromJson(
  1. Map<String, dynamic> json
)

Creates configuration from JSON

Implementation

factory IPFSConfig.fromJson(Map<String, dynamic> json) {
  return IPFSConfig(
    offline: json['offline'] as bool? ?? false,
    network: NetworkConfig.fromJson(
      json['network'] != null
          ? Map<String, dynamic>.from(json['network'] as Map)
          : {},
    ),
    dht: DHTConfig.fromJson(
      json['dht'] != null
          ? Map<String, dynamic>.from(json['dht'] as Map)
          : {},
    ),
    storage: StorageConfig.fromJson(
      json['storage'] != null
          ? Map<String, dynamic>.from(json['storage'] as Map)
          : {},
    ),
    security: SecurityConfig.fromJson(
      json['security'] != null
          ? Map<String, dynamic>.from(json['security'] as Map)
          : {},
    ),
    gateway: json['gateway'] != null
        ? GatewayConfig.fromJson(
            Map<String, dynamic>.from(json['gateway'] as Map),
          )
        : null,
    bitswap: json['bitswap'] != null
        ? BitswapConfig.fromJson(
            Map<String, dynamic>.from(json['bitswap'] as Map),
          )
        : const BitswapConfig(),
    graphsync: json['graphsync'] != null
        ? GraphsyncConfig.fromJson(
            Map<String, dynamic>.from(json['graphsync'] as Map),
          )
        : const GraphsyncConfig(),
    debug: json['debug'] as bool? ?? false,
    verboseLogging: json['verboseLogging'] as bool? ?? false,
    enablePubSub: json['enablePubSub'] as bool? ?? true,
    enableDHT: json['enableDHT'] as bool? ?? true,
    enableRPC: json['enableRPC'] as bool? ?? false,
    enableCircuitRelay: json['enableCircuitRelay'] as bool? ?? true,
    enableContentRouting: json['enableContentRouting'] as bool? ?? true,
    enableDNSLinkResolution: json['enableDNSLinkResolution'] as bool? ?? true,
    enableIPLD: json['enableIPLD'] as bool? ?? true,
    enableGraphsync: json['enableGraphsync'] as bool? ?? true,
    enableMetrics: json['enableMetrics'] as bool? ?? true,
    enableIpnsPubSub: json['enableIpnsPubSub'] as bool? ?? false,
    enableLogging: json['enableLogging'] as bool? ?? true,
    enableStructuredLogging:
        json['enableStructuredLogging'] as bool? ?? false,
    logLevel: json['logLevel'] as String? ?? 'info',
    enableQuotaManagement: json['enableQuotaManagement'] as bool? ?? true,
    defaultBandwidthQuota: json['defaultBandwidthQuota'] as int? ?? 1048576,
    maxConcurrentBitswapRequests:
        json['maxConcurrentBitswapRequests'] as int? ?? 10,
    maxSelectorDepth: json['maxSelectorDepth'] as int? ?? 32,
    maxSelectorNodes: json['maxSelectorNodes'] as int? ?? 10000,
    ipnsCacheSize: json['ipnsCacheSize'] as int? ?? 1000,
    garbageCollectionInterval: Duration(
      seconds: json['garbageCollectionInterval'] as int? ?? 86400,
    ),
    garbageCollectionEnabled:
        json['garbageCollectionEnabled'] as bool? ?? true,
    datastorePath: json['datastorePath'] as String? ?? './ipfs_data',
    keystorePath: json['keystorePath'] as String? ?? './ipfs_keystore',
    blockStorePath: json['blockStorePath'] as String? ?? 'blocks',
    dataPath: json['dataPath'] as String? ?? './ipfs_data',
    enableLibp2pBridge: json['enableLibp2pBridge'] as bool? ?? false,
    libp2pListenAddress:
        json['libp2pListenAddress'] as String? ?? '/ip4/0.0.0.0/tcp/4001',
    nodeId: json['nodeId'] as String?,
    libp2pIdentitySeed: json['libp2pIdentitySeed'] != null
        ? base64Decode(json['libp2pIdentitySeed'] as String)
        : null,
    metrics: json['metrics'] != null
        ? MetricsConfig.fromJson(
            Map<String, dynamic>.from(json['metrics'] as Map),
          )
        : const MetricsConfig(),
    customConfig: Map<String, dynamic>.from(
      json['customConfig'] as Map? ?? const {},
    ),
  );
}