BitswapConfig.fromJson constructor

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

Creates a BitswapConfig from a JSON map.

Implementation

factory BitswapConfig.fromJson(Map<String, dynamic> json) {
  return BitswapConfig(
    maxConcurrentRequests: json['maxConcurrentRequests'] as int? ?? 10,
    httpFallbackGateways:
        (json['httpFallbackGateways'] as List?)?.cast<String>() ??
        const <String>[],
    p2pTimeout: json['p2pTimeoutSeconds'] != null
        ? Duration(seconds: json['p2pTimeoutSeconds'] as int)
        : const Duration(seconds: 30),
    httpTimeout: json['httpTimeoutSeconds'] != null
        ? Duration(seconds: json['httpTimeoutSeconds'] as int)
        : const Duration(seconds: 10),
    enableHttpFallback: json['enableHttpFallback'] as bool? ?? false,
    maxHttpBlockSize: json['maxHttpBlockSize'] as int? ?? 2 * 1024 * 1024,
    allowPrivateGateways: json['allowPrivateGateways'] as bool? ?? false,
    // verifyHttpBlocks is intentionally not exposed in serialised config.
  );
}