class MiningTaskInfo {
  final String coin;
  final String algo;
  final String pool;
  final String poolUrl;
  final String walletAddress;
  final String workerId;
  final String? poolUser;
  final bool walletMining;
  final int endTimestamp;
  final String miner; // 从配置或请求中获取

  MiningTaskInfo({
    required this.coin,
    required this.algo,
    required this.pool,
    required this.poolUrl,
    required this.walletAddress,
    required this.workerId,
    this.poolUser,
    required this.walletMining,
    required this.endTimestamp,
    required this.miner,
  });

  factory MiningTaskInfo.fromJson(Map<String, dynamic> json) {
    return MiningTaskInfo(
      coin: json['coin'] as String,
      algo: json['algo'] as String,
      pool: json['pool'] as String,
      poolUrl: json['pool_url'] as String,
      walletAddress: json['wallet_address'] as String,
      workerId: json['worker_id'] as String,
      poolUser: json['pool_user'] as String?,
      walletMining: json['wallet_mining'] as bool? ?? true,
      endTimestamp: json['end_timestamp'] as int,
      miner: json['miner'] as String? ?? 'lolminer', // 默认值
    );
  }
}
