# frozen_string_literal: true

module SynorMining
  # Device types
  module DeviceType
    CPU = "cpu"
    GPU_NVIDIA = "gpu_nvidia"
    GPU_AMD = "gpu_amd"
    ASIC = "asic"
  end

  # Device status
  module DeviceStatus
    IDLE = "idle"
    MINING = "mining"
    ERROR = "error"
    OFFLINE = "offline"
  end

  # Connection status
  module ConnectionStatus
    DISCONNECTED = "disconnected"
    CONNECTING = "connecting"
    CONNECTED = "connected"
    RECONNECTING = "reconnecting"
  end

  # Time periods
  module TimePeriod
    HOUR = "hour"
    DAY = "day"
    WEEK = "week"
    MONTH = "month"
    ALL = "all"
  end

  # Submit status
  module SubmitStatus
    ACCEPTED = "accepted"
    REJECTED = "rejected"
    STALE = "stale"
  end

  # Configuration
  Config = Struct.new(:api_key, :endpoint, :timeout, :retries, :debug, keyword_init: true) do
    def initialize(api_key:, endpoint: "https://mining.synor.io/v1", timeout: 60, retries: 3, debug: false)
      super
    end
  end

  # Data types
  PoolConfig = Struct.new(:url, :user, :password, :algorithm, :difficulty, keyword_init: true)

  StratumConnection = Struct.new(:id, :pool, :status, :algorithm, :difficulty, :connected_at, :accepted_shares, :rejected_shares, :stale_shares, :last_share_at, keyword_init: true)

  PoolStats = Struct.new(:url, :workers, :hashrate, :difficulty, :last_block, :blocks_found_24h, :luck, keyword_init: true)

  TemplateTransaction = Struct.new(:txid, :data, :fee, :weight, keyword_init: true)

  BlockTemplate = Struct.new(:id, :previous_block_hash, :merkle_root, :timestamp, :bits, :height, :coinbase_value, :transactions, :target, :algorithm, :extra_nonce, keyword_init: true)

  MinedWork = Struct.new(:template_id, :nonce, :extra_nonce, :timestamp, :hash, keyword_init: true)

  ShareInfo = Struct.new(:hash, :difficulty, :timestamp, :accepted, keyword_init: true)

  SubmitResult = Struct.new(:status, :share, :block_found, :reason, :block_hash, :reward, keyword_init: true)

  Hashrate = Struct.new(:current, :average_1h, :average_24h, :peak, :unit, keyword_init: true)

  ShareStats = Struct.new(:accepted, :rejected, :stale, :total, :accept_rate, keyword_init: true)

  DeviceTemperature = Struct.new(:current, :max, :throttling, keyword_init: true)

  EarningsSnapshot = Struct.new(:today, :yesterday, :this_week, :this_month, :total, :currency, keyword_init: true)

  MiningStats = Struct.new(:hashrate, :shares, :uptime, :efficiency, :earnings, :power_consumption, :temperature, keyword_init: true)

  EarningsBreakdown = Struct.new(:date, :amount, :blocks, :shares, :hashrate, keyword_init: true)

  Earnings = Struct.new(:period, :start_date, :end_date, :amount, :blocks, :shares, :average_hashrate, :currency, :breakdown, keyword_init: true)

  MiningDevice = Struct.new(:id, :name, :type, :status, :hashrate, :temperature, :fan_speed, :power_draw, :memory_used, :memory_total, :driver, :firmware, keyword_init: true)

  DeviceConfig = Struct.new(:enabled, :intensity, :power_limit, :core_clock_offset, :memory_clock_offset, :fan_speed, keyword_init: true)

  WorkerInfo = Struct.new(:id, :name, :status, :hashrate, :shares, :devices, :last_seen, :uptime, keyword_init: true)

  MiningAlgorithm = Struct.new(:name, :display_name, :hash_unit, :profitability, :difficulty, :block_reward, :block_time, keyword_init: true)
end
