DHTConfig.fromJson constructor
Creates a DHTConfig from JSON.
@param json The JSON map to parse. @return A new DHTConfig instance.
Implementation
factory DHTConfig.fromJson(Map<String, dynamic> json) {
return DHTConfig(
protocolId: (json['protocolId'] as String?) ?? '/ipfs/kad/1.0.0',
alpha: (json['alpha'] as int?) ?? 3,
bucketSize: (json['bucketSize'] as int?) ?? 20,
maxProvidersPerKey: (json['maxProvidersPerKey'] as int?) ?? 20,
requestTimeout: Duration(
seconds: (json['requestTimeoutSeconds'] as int?) ?? 30,
),
maxRecordsPerQuery: (json['maxRecordsPerQuery'] as int?) ?? 20,
enableProviderRecording:
(json['enableProviderRecording'] as bool?) ?? true,
enableValueStorage: (json['enableValueStorage'] as bool?) ?? true,
validateProviderRecords:
(json['validateProviderRecords'] as bool?) ?? true,
reproviderEnabled: (json['reproviderEnabled'] as bool?) ?? true,
reproviderInterval: Duration(
seconds: (json['reproviderIntervalSeconds'] as int?) ?? 43200,
),
reproviderStrategy: (json['reproviderStrategy'] as String?) ?? 'pinned',
reproviderBatchSize: (json['reproviderBatchSize'] as int?) ?? 100,
reproviderConcurrency: (json['reproviderConcurrency'] as int?) ?? 10,
reproviderSweepOptimization:
(json['reproviderSweepOptimization'] as bool?) ?? true,
);
}